Skip to content

Commit

Permalink
ed
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammed-Ramadan512 committed Nov 15, 2023
1 parent a589261 commit f09d9f0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
84 changes: 42 additions & 42 deletions lib/src/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
print(e);
}

print(
debugPrint(
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ${currentPosition.toString()}");
// widgetsBinding.addPersistentFrameCallback((callback) {
var orientation = MediaQuery.of(context).orientation;
Expand Down Expand Up @@ -313,7 +313,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
Text(playbackSpeed.toString() + " x",
style: widget.videoStyle!.qualitystyle),
() {
print("speeed");
debugPrint("speeed");
setState(() {
m3u8showspeed = !m3u8showspeed;
m3u8show = false;
Expand Down Expand Up @@ -376,7 +376,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
m3u8showspeed = false;
});

print("--- speed select : $e");
debugPrint("--- speed select : $e");
},
child: Container(
width: 90,
Expand Down Expand Up @@ -413,7 +413,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
m3u8show = false;
});
onSelectQuality(e);
print(
debugPrint(
"--- quality select ---\nquality : ${e.dataQuality}\nlink : ${e.dataURL}");
},
child: Container(
Expand Down Expand Up @@ -465,7 +465,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
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;
Expand All @@ -474,38 +474,38 @@ class _YoYoPlayerState extends State<YoYoPlayer>
setState(() {
playType = "MKV";
});
print("urlEnd : mkv");
debugPrint("urlEnd : mkv");
if (widget.onPlayingVideo != null) widget.onPlayingVideo!("MKV");

videoControlSetup(url);
} else if (a.pathSegments.last.endsWith("mp4")) {
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(() {
playType = "HLS";
});
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);
Expand All @@ -516,10 +516,10 @@ class _YoYoPlayerState extends State<YoYoPlayer>
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);
Expand All @@ -541,7 +541,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
setState(
() {
if (m3u8Content != null) {
print("--- HLS Old Data ----\n$m3u8Content");
debugPrint("--- HLS Old Data ----\n$m3u8Content");
m3u8Content = null;
}
},
Expand All @@ -555,7 +555,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
List<RegExpMatch> matches = regExp.allMatches(m3u8Content!).toList();
List<RegExpMatch> audioMatches =
regExpAudio.allMatches(m3u8Content!).toList();
print(
debugPrint(
"--- HLS Data ----\n$m3u8Content \ntotal length: ${yoyo.length} \nfinish");

matches.forEach(
Expand All @@ -573,7 +573,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
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 {
Expand All @@ -587,33 +587,33 @@ class _YoYoPlayerState extends State<YoYoPlayer>
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""";
} else {
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;
}
Expand Down Expand Up @@ -720,7 +720,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>

void videoInit(String? url) {
if (offline == false) {
print(
debugPrint(
"--- Player Status ---\nplay url : $url\noffline : $offline\n--- start playing –––");

if (playType == "MP4") {
Expand Down Expand Up @@ -754,12 +754,12 @@ class _YoYoPlayerState extends State<YoYoPlayer>
}
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((_) {
Expand All @@ -769,7 +769,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
setState(() => hasInitError = false);
}
}).catchError((e) {
print(e);
debugPrint(e);
setState(() => hasInitError = true);
});
}
Expand Down Expand Up @@ -811,22 +811,22 @@ class _YoYoPlayerState extends State<YoYoPlayer>
} 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());

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}");
}
}

Expand All @@ -847,7 +847,7 @@ class _YoYoPlayerState extends State<YoYoPlayer>
// controller!.play();
}).catchError((e) {
setState(() => hasInitError = true);
print('Init local file error $e');
debugPrint('Init local file error $e');
});

controller!.addListener(listener);
Expand All @@ -861,36 +861,36 @@ class _YoYoPlayerState extends State<YoYoPlayer>
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);
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/src/widget/widget_bottombar.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit f09d9f0

Please sign in to comment.