Closed aimsson closed 1 month ago
a workaround for now is adding player.setMedia('', MediaType.audio);
in videoWithAudio. I will fix it later
void videoWithAudio() {
player.setMedia('', MediaType.audio);
player.media = 'https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_30mb.mp4';
player.prepare().then((int position) {
debugPrint('Pos "Regular video with audio" after prepare: $position');
debugPrint('PlaybackState after .prepare: ${player.state}');
if (!position.isNegative) {
}
});
}
for dead lock, you have to set stop state before prepare
void videoNoAudioExternalAudioStream() {
player.state = PlaybackState.stopped;
player.media = 'https://getsamplefiles.com/download/mkv/sample-3.mkv';
player.prepare().then((int position) {
debugPrint('Pos "Muted video + audio stream" after prepare: $position');
debugPrint('PlaybackState after .prepare: ${player.state}');
if (!position.isNegative) {
player.setMedia('https://stream.tunerplay.com/radio/8020/jazzradiospain.mp3', MediaType.audio);
}
});
}
void videoWithAudio() {
player.state = PlaybackState.stopped;
player.setMedia('', MediaType.audio);
player.media = 'https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_30mb.mp4';
player.prepare().then((int position) {
debugPrint('Pos "Regular video with audio" after prepare: $position');
debugPrint('PlaybackState after .prepare: ${player.state}');
if (!position.isNegative) {
}
});
}
run
pod cache clean mdk
pod deintegrate macos/Runner.xcodeproj
rm macos/Podfile.lock
and build again, then no need to call player.setMedia('', MediaType.audio);
run
pod cache clean mdk pod deintegrate macos/Runner.xcodeproj rm macos/Podfile.lock
and build again, then no need to call
player.setMedia('', MediaType.audio);
yep, did it
but I'm still getting troubles with playback and deadlocks. Now the nosound video lags really bad, sometimes it doesnt. The big buck bunny is unpredictable too, it can lag or not. I've made a new video and log youtube pastebin
run
pod cache clean mdk pod deintegrate macos/Runner.xcodeproj rm macos/Podfile.lock
and build again, then no need to call
player.setMedia('', MediaType.audio);
yep, did it
mdk version is not correct from the log. maybe you have to run rm -rf macos/Pods
after above commands
Yes, after removing the Pods folder and building again everything turned out to be fine. @wang-bin thank you very much for your help and blazingly fast replies. I really love the backend player api, it's awesome! Would you be so kind to answer one more question - should I always switch video sources through setting PlaybackState.stopped or is there any way of "hot" swapping the video source?
must stop current then play a new one. there is another api setNext
, it will preload the video, and play gaplessly when current is stopped, but does not support individual audio track source.
Describe the bug The example is based on a modified mdk-examples/flutter/simple/lib/multi_textures.dart. The player starts with a single video file (no audio, no subtitles), after .prepare it I added the external audio track (online radio stream) via .setMedia. Everything was fine, video playback went smoothly, audio worked well. If I do switch to another regular (video track + audio track) mp4, video and audio playback become choppy. Stop/restart dont help. The app can also fall into deadlock in between switching media source or at a try to set PlaybackState.stopped with no log message. I have recorded the explanation video: youtube
Expected behavior Expected smooth playback like when the .setMedia line with external audio is commented out. Also expected some error log entry at deadlock moment. Deadlock can happen even with a commented out .setMedia
Example Code
Complete Log of a video explanation pastebin