From f09d9f069d32f105003f01e02f270d04893cfc8b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Nov 2023 19:48:41 +0200 Subject: [PATCH] ed --- lib/src/video.dart | 84 ++++++++++++++-------------- lib/src/widget/widget_bottombar.dart | 1 - 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/lib/src/video.dart b/lib/src/video.dart index df2db9f..0efbf40 100644 --- a/lib/src/video.dart +++ b/lib/src/video.dart @@ -199,7 +199,7 @@ class _YoYoPlayerState extends State print(e); } - print( + debugPrint( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ${currentPosition.toString()}"); // widgetsBinding.addPersistentFrameCallback((callback) { var orientation = MediaQuery.of(context).orientation; @@ -313,7 +313,7 @@ class _YoYoPlayerState extends State Text(playbackSpeed.toString() + " x", style: widget.videoStyle!.qualitystyle), () { - print("speeed"); + debugPrint("speeed"); setState(() { m3u8showspeed = !m3u8showspeed; m3u8show = false; @@ -376,7 +376,7 @@ class _YoYoPlayerState extends State m3u8showspeed = false; }); - print("--- speed select : $e"); + debugPrint("--- speed select : $e"); }, child: Container( width: 90, @@ -413,7 +413,7 @@ class _YoYoPlayerState extends State m3u8show = false; }); onSelectQuality(e); - print( + debugPrint( "--- quality select ---\nquality : ${e.dataQuality}\nlink : ${e.dataURL}"); }, child: Container( @@ -465,7 +465,7 @@ class _YoYoPlayerState extends State final isNetwork = netRegex.hasMatch(url); final a = Uri.parse(url); - print("parse url data end : ${a.pathSegments.last}"); + debugPrint("parse url data end : ${a.pathSegments.last}"); if (isNetwork) { setState(() { offline = false; @@ -474,7 +474,7 @@ class _YoYoPlayerState extends State setState(() { playType = "MKV"; }); - print("urlEnd : mkv"); + debugPrint("urlEnd : mkv"); if (widget.onPlayingVideo != null) widget.onPlayingVideo!("MKV"); videoControlSetup(url); @@ -482,10 +482,10 @@ class _YoYoPlayerState extends State setState(() { playType = "MP4"; }); - print("urlEnd : mp4 $playType"); + debugPrint("urlEnd : mp4 $playType"); if (widget.onPlayingVideo != null) widget.onPlayingVideo!("MP4"); - print("urlEnd : mp4"); + debugPrint("urlEnd : mp4"); videoControlSetup(url); } else if (a.pathSegments.last.endsWith("m3u8")) { setState(() { @@ -493,19 +493,19 @@ class _YoYoPlayerState extends State }); if (widget.onPlayingVideo != null) widget.onPlayingVideo!("M3U8"); - print("urlEnd : m3u8"); + debugPrint("urlEnd : m3u8"); videoControlSetup(url); getM3U8(url); } else { - print("urlEnd : null"); + debugPrint("urlEnd : null"); videoControlSetup(url); getM3U8(url); } - print("--- Current Video Status ---\noffline : $offline"); + debugPrint("--- Current Video Status ---\noffline : $offline"); } else { setState(() { offline = true; - print( + debugPrint( "--- Current Video Status ---\noffline : $offline \n --- :3 done url check ---"); }); videoControlSetup(url); @@ -516,10 +516,10 @@ class _YoYoPlayerState extends State void getM3U8(String video) { try { if (yoyo.length > 0) { - print("${yoyo.length} : data start clean"); + debugPrint("${yoyo.length} : data start clean"); m3u8clean(); } - print("---- m3u8 fitch start ----\n$video\n--- please wait –––"); + debugPrint("---- m3u8 fitch start ----\n$video\n--- please wait –––"); m3u8video(video); } catch (e) { print(e); @@ -541,7 +541,7 @@ class _YoYoPlayerState extends State setState( () { if (m3u8Content != null) { - print("--- HLS Old Data ----\n$m3u8Content"); + debugPrint("--- HLS Old Data ----\n$m3u8Content"); m3u8Content = null; } }, @@ -555,7 +555,7 @@ class _YoYoPlayerState extends State List matches = regExp.allMatches(m3u8Content!).toList(); List audioMatches = regExpAudio.allMatches(m3u8Content!).toList(); - print( + debugPrint( "--- HLS Data ----\n$m3u8Content \ntotal length: ${yoyo.length} \nfinish"); matches.forEach( @@ -573,7 +573,7 @@ class _YoYoPlayerState extends State print(match); final dataURL = match!.group(0); url = "$dataURL$sourceURL"; - print("--- hls child url integration ---\nchild url :$url"); + debugPrint("--- hls child url integration ---\nchild url :$url"); } audioMatches.forEach( (RegExpMatch regExpMatch2) async { @@ -587,14 +587,14 @@ class _YoYoPlayerState extends State print(match); final auDataURL = match!.group(0); auURL = "$auDataURL$audioURL"; - print("url network audio $url $audioURL"); + debugPrint("url network audio $url $audioURL"); } audioList.add(AUDIO(url: auURL)); - print(audioURL); + debugPrint(audioURL); }, ); String audio = ""; - print("-- audio ---\naudio list length :${audio.length}"); + debugPrint("-- audio ---\naudio list length :${audio.length}"); if (audioList.length != 0) { audio = """#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-medium",NAME="audio",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="${audioList.last.url}"\n"""; @@ -602,18 +602,18 @@ class _YoYoPlayerState extends State audio = ""; } try { - final Directory directory = await getApplicationDocumentsDirectory(); + final Directory directory = await getApplicationSupportDirectory(); final File file = File('${directory.path}/yoyo$quality.m3u8'); await file.writeAsString( """#EXTM3U\n#EXT-X-INDEPENDENT-SEGMENTS\n$audio#EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,BANDWIDTH=1469712,RESOLUTION=$quality,FRAME-RATE=30.000\n$url"""); } catch (e) { - print("Couldn't write file"); + debugPrint("Couldn't write file"); } yoyo.add(M3U8pass(dataQuality: quality, dataURL: url)); }, ); M3U8s m3u8s = M3U8s(m3u8s: yoyo); - print( + debugPrint( "--- m3u8 file write ---\n${yoyo.map((e) => e.dataQuality == e.dataURL).toList()}\nlength : ${yoyo.length}\nSuccess"); return m3u8s; } @@ -720,7 +720,7 @@ class _YoYoPlayerState extends State void videoInit(String? url) { if (offline == false) { - print( + debugPrint( "--- Player Status ---\nplay url : $url\noffline : $offline\n--- start playing –––"); if (playType == "MP4") { @@ -754,12 +754,12 @@ class _YoYoPlayerState extends State } setState(() => hasInitError = false); }).catchError((e) { - print(e); + debugPrint(e); setState(() => hasInitError = true); }); } } else { - print( + debugPrint( "--- Player Status ---\nplay url : $url\noffline : $offline\n--- start playing –––"); controller = VideoPlayerController.file(File(url!)) ..initialize().then((_) { @@ -769,7 +769,7 @@ class _YoYoPlayerState extends State setState(() => hasInitError = false); } }).catchError((e) { - print(e); + debugPrint(e); setState(() => hasInitError = true); }); } @@ -811,12 +811,12 @@ class _YoYoPlayerState extends State } else { try { String text; - final Directory directory = await getApplicationDocumentsDirectory(); + final Directory directory = await getApplicationSupportDirectory(); final File file = File('${directory.path}/yoyo${data.dataQuality}.m3u8'); - print("read file success"); + debugPrint("read file success"); text = await file.readAsString(); - print("data : $text :: data"); + debugPrint("data : $text :: data"); storage?.write( key: widget.url, value: controller!.value.position.inSeconds.toString()); @@ -824,9 +824,9 @@ class _YoYoPlayerState extends State localM3U8play(data.dataURL!); // videoControlSetup(file); } catch (e) { - print("Couldn't read file ${data.dataQuality} e: $e"); + debugPrint("Couldn't read file ${data.dataQuality} e: $e"); } - print("data : ${data.dataQuality}"); + debugPrint("data : ${data.dataQuality}"); } } @@ -847,7 +847,7 @@ class _YoYoPlayerState extends State // controller!.play(); }).catchError((e) { setState(() => hasInitError = true); - print('Init local file error $e'); + debugPrint('Init local file error $e'); }); controller!.addListener(listener); @@ -861,36 +861,36 @@ class _YoYoPlayerState extends State print(yoyo.length); for (int i = 2; i < yoyo.length; i++) { try { - final Directory directory = await getApplicationDocumentsDirectory(); + final Directory directory = await getApplicationSupportDirectory(); final File file = File('${directory.path}/${yoyo[i].dataQuality}.m3u8'); file.delete(); - print("delete success $file"); + debugPrint("delete success $file"); } catch (e) { - print("Couldn't delete file $e"); + debugPrint("Couldn't delete file $e"); } } try { - print("Audio m3u8 list clean"); + debugPrint("Audio m3u8 list clean"); audioList.clear(); } catch (e) { - print("Audio list clean error $e"); + debugPrint("Audio list clean error $e"); } // audioList.clear(); try { - print("m3u8 data list clean"); + debugPrint("m3u8 data list clean"); yoyo.clear(); } catch (e) { - print("m3u8 video list clean error $e"); + debugPrint("m3u8 video list clean error $e"); } } void toggleFullScreen() { // if (fullScreen) { if (MediaQuery.of(context).orientation == Orientation.landscape) { - print("full up"); + debugPrint("full up"); OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp); } else { - print("full land right"); + debugPrint("full land right"); OrientationPlugin.forceOrientation(DeviceOrientation.landscapeRight); } } diff --git a/lib/src/widget/widget_bottombar.dart b/lib/src/widget/widget_bottombar.dart index 21685d9..8d3e416 100644 --- a/lib/src/widget/widget_bottombar.dart +++ b/lib/src/widget/widget_bottombar.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:smooth_video_progress/smooth_video_progress.dart'; import 'package:video_player/video_player.dart';