Showing
5 changed files
with
31 additions
and
19 deletions
| ... | @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; | ... | @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; |
| 6 | import 'package:getwidget/getwidget.dart'; | 6 | import 'package:getwidget/getwidget.dart'; |
| 7 | import 'package:path_provider/path_provider.dart'; | 7 | import 'package:path_provider/path_provider.dart'; |
| 8 | import 'package:share_plus/share_plus.dart'; | 8 | import 'package:share_plus/share_plus.dart'; |
| 9 | +import '../../events/trans_event.dart'; | ||
| 9 | import '../../net/dio_utils.dart'; | 10 | import '../../net/dio_utils.dart'; |
| 10 | import '../../net/http_api.dart'; | 11 | import '../../net/http_api.dart'; |
| 11 | import '../theme/tik_video_player.dart'; | 12 | import '../theme/tik_video_player.dart'; |
| ... | @@ -41,10 +42,10 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -41,10 +42,10 @@ class VideoSlidesState extends State<VideoSlides> { |
| 41 | super.initState(); | 42 | super.initState(); |
| 42 | isPraise = widget.isPraise; | 43 | isPraise = widget.isPraise; |
| 43 | isCollect = widget.isCollect; | 44 | isCollect = widget.isCollect; |
| 44 | - recodeVideoPlayStatus(); | 45 | + recordVideoPlayStatus(); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | - Future<void> recodeVideoPlayStatus() async { | 48 | + Future<void> recordVideoPlayStatus() async { |
| 48 | String url = '${HttpApi.addView}/${widget.videoId}'; | 49 | String url = '${HttpApi.addView}/${widget.videoId}'; |
| 49 | // 统计观看数 | 50 | // 统计观看数 |
| 50 | DioUtils.instance.asyncRequestNetwork( | 51 | DioUtils.instance.asyncRequestNetwork( |
| ... | @@ -125,7 +126,7 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -125,7 +126,7 @@ class VideoSlidesState extends State<VideoSlides> { |
| 125 | child: InkWell( | 126 | child: InkWell( |
| 126 | onTap: () { | 127 | onTap: () { |
| 127 | isPraise = | 128 | isPraise = |
| 128 | - isPraise == false ? true : false; | 129 | + isPraise == false ? true : false; |
| 129 | setState(() {}); | 130 | setState(() {}); |
| 130 | String url = | 131 | String url = |
| 131 | '${HttpApi.praise}/${widget.videoId}'; | 132 | '${HttpApi.praise}/${widget.videoId}'; |
| ... | @@ -176,7 +177,7 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -176,7 +177,7 @@ class VideoSlidesState extends State<VideoSlides> { |
| 176 | child: InkWell( | 177 | child: InkWell( |
| 177 | onTap: () async { | 178 | onTap: () async { |
| 178 | isCollect = | 179 | isCollect = |
| 179 | - isCollect == false ? true : false; | 180 | + isCollect == false ? true : false; |
| 180 | setState(() {}); | 181 | setState(() {}); |
| 181 | String url = | 182 | String url = |
| 182 | '${HttpApi.collect}/${widget.videoId}'; | 183 | '${HttpApi.collect}/${widget.videoId}'; |
| ... | @@ -242,14 +243,14 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -242,14 +243,14 @@ class VideoSlidesState extends State<VideoSlides> { |
| 242 | ), | 243 | ), |
| 243 | child: isSharing | 244 | child: isSharing |
| 244 | ? GFProgressBar( | 245 | ? GFProgressBar( |
| 245 | - percentage: currentProgress, | 246 | + percentage: currentProgress, |
| 246 | - backgroundColor: Colors.black26, | 247 | + backgroundColor: Colors.black26, |
| 247 | - progressBarColor: GFColors.DANGER) | 248 | + progressBarColor: GFColors.DANGER) |
| 248 | : const Icon( | 249 | : const Icon( |
| 249 | - Icons.share_rounded, | 250 | + Icons.share_rounded, |
| 250 | - color: Colors.white, | 251 | + color: Colors.white, |
| 251 | - size: 20, | 252 | + size: 20, |
| 252 | - ), | 253 | + ), |
| 253 | ), | 254 | ), |
| 254 | ), | 255 | ), |
| 255 | ), | 256 | ), |
| ... | @@ -278,6 +279,7 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -278,6 +279,7 @@ class VideoSlidesState extends State<VideoSlides> { |
| 278 | icon: const Icon(Icons.video_call_outlined), | 279 | icon: const Icon(Icons.video_call_outlined), |
| 279 | buttonColor: Colors.teal, | 280 | buttonColor: Colors.teal, |
| 280 | onPress: () { | 281 | onPress: () { |
| 282 | + eventBus.fire(TransEvent()); | ||
| 281 | String url = | 283 | String url = |
| 282 | '${PoemRouter.poemRecordVideoPage}?id=${widget.videoId}&type=${widget.poemType}'; | 284 | '${PoemRouter.poemRecordVideoPage}?id=${widget.videoId}&type=${widget.poemType}'; |
| 283 | NavigatorUtils.push( | 285 | NavigatorUtils.push( |
| ... | @@ -289,6 +291,7 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -289,6 +291,7 @@ class VideoSlidesState extends State<VideoSlides> { |
| 289 | icon: const Icon(Icons.mic_none_outlined), | 291 | icon: const Icon(Icons.mic_none_outlined), |
| 290 | buttonColor: Colors.green, | 292 | buttonColor: Colors.green, |
| 291 | onPress: () { | 293 | onPress: () { |
| 294 | + eventBus.fire(TransEvent()); | ||
| 292 | NavigatorUtils.push( | 295 | NavigatorUtils.push( |
| 293 | context, | 296 | context, |
| 294 | '${PoemRouter.poemRecordAudioPage}?id=${widget.videoId}&type=${widget.poemType}', | 297 | '${PoemRouter.poemRecordAudioPage}?id=${widget.videoId}&type=${widget.poemType}', |
| ... | @@ -319,10 +322,10 @@ class VideoSlidesState extends State<VideoSlides> { | ... | @@ -319,10 +322,10 @@ class VideoSlidesState extends State<VideoSlides> { |
| 319 | tempVideoPath = "$savePath$appName"; | 322 | tempVideoPath = "$savePath$appName"; |
| 320 | Response response = await dio.download(url, tempVideoPath, | 323 | Response response = await dio.download(url, tempVideoPath, |
| 321 | onReceiveProgress: (received, total) { | 324 | onReceiveProgress: (received, total) { |
| 322 | - if (total != -1) { | 325 | + if (total != -1) { |
| 323 | - currentProgress = received / total; | 326 | + currentProgress = received / total; |
| 324 | - setState(() {}); | 327 | + setState(() {}); |
| 325 | - } | 328 | + } |
| 326 | - }); | 329 | + }); |
| 327 | } | 330 | } |
| 328 | } | 331 | } | ... | ... |
| ... | @@ -73,7 +73,7 @@ class _PoemCompletePageState extends State<PoemCompletePage> { | ... | @@ -73,7 +73,7 @@ class _PoemCompletePageState extends State<PoemCompletePage> { |
| 73 | onPressed: () { | 73 | onPressed: () { |
| 74 | NavigatorUtils.push( | 74 | NavigatorUtils.push( |
| 75 | context, | 75 | context, |
| 76 | - Routes.home, | 76 | + Routes.navBarPage, |
| 77 | clearStack: true, | 77 | clearStack: true, |
| 78 | ); | 78 | ); |
| 79 | }, | 79 | }, | ... | ... |
| ... | @@ -164,7 +164,7 @@ class AudioToolBar extends StatefulWidget { | ... | @@ -164,7 +164,7 @@ class AudioToolBar extends StatefulWidget { |
| 164 | class _AudioToolBarState extends State<AudioToolBar> { | 164 | class _AudioToolBarState extends State<AudioToolBar> { |
| 165 | late final PausableTimer _timer; | 165 | late final PausableTimer _timer; |
| 166 | int currentTimer = 0; | 166 | int currentTimer = 0; |
| 167 | - int duration = 10 * 1000; //TODO 60 * 1000; | 167 | + int duration = 60 * 1000; |
| 168 | 168 | ||
| 169 | Codec _codec = Codec.aacMP4; //TODO why accMP4? | 169 | Codec _codec = Codec.aacMP4; //TODO why accMP4? |
| 170 | String _mPath = 'tau_file.mp4'; | 170 | String _mPath = 'tau_file.mp4'; | ... | ... |
| ... | @@ -51,7 +51,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> | ... | @@ -51,7 +51,7 @@ class PoemRecordVideoPageState extends State<PoemRecordVideoPage> |
| 51 | 51 | ||
| 52 | late final PausableTimer _timer; | 52 | late final PausableTimer _timer; |
| 53 | int currentTimer = 0; | 53 | int currentTimer = 0; |
| 54 | - int duration = 10 * 1000; //TODO 60 * 1000; | 54 | + int duration = 60 * 1000; |
| 55 | 55 | ||
| 56 | @override | 56 | @override |
| 57 | void initState() { | 57 | void initState() { | ... | ... |
| 1 | +import 'dart:async'; | ||
| 2 | + | ||
| 3 | +import 'package:Parlando/events/trans_event.dart'; | ||
| 1 | import 'package:chewie/chewie.dart'; | 4 | import 'package:chewie/chewie.dart'; |
| 2 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
| 3 | import 'package:flutter/services.dart'; | 6 | import 'package:flutter/services.dart'; |
| ... | @@ -43,17 +46,23 @@ class TikVideoPlayer extends StatefulWidget { | ... | @@ -43,17 +46,23 @@ class TikVideoPlayer extends StatefulWidget { |
| 43 | class _TikVideoPlayerState extends State<TikVideoPlayer> { | 46 | class _TikVideoPlayerState extends State<TikVideoPlayer> { |
| 44 | late VideoPlayerController _videoPlayerController; | 47 | late VideoPlayerController _videoPlayerController; |
| 45 | ChewieController? _chewieController; | 48 | ChewieController? _chewieController; |
| 49 | + late StreamSubscription bus; | ||
| 46 | 50 | ||
| 47 | @override | 51 | @override |
| 48 | void initState() { | 52 | void initState() { |
| 49 | initializePlayer(); | 53 | initializePlayer(); |
| 50 | super.initState(); | 54 | super.initState(); |
| 55 | + | ||
| 56 | + bus = eventBus.on<TransEvent>().listen((event) { | ||
| 57 | + _chewieController!.videoPlayerController.pause(); | ||
| 58 | + }); | ||
| 51 | } | 59 | } |
| 52 | 60 | ||
| 53 | @override | 61 | @override |
| 54 | void dispose() { | 62 | void dispose() { |
| 55 | _videoPlayerController.dispose(); | 63 | _videoPlayerController.dispose(); |
| 56 | _chewieController!.dispose(); | 64 | _chewieController!.dispose(); |
| 65 | + bus.cancel(); | ||
| 57 | super.dispose(); | 66 | super.dispose(); |
| 58 | } | 67 | } |
| 59 | 68 | ... | ... |
-
Please register or login to post a comment