Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
762 stars 305 forks source link

Duration value is doubled (Special case on youtube streaming) #832

Open daryle2000 opened 2 years ago

daryle2000 commented 2 years ago

🐛 Bug Report

Just tested MediaManager on playing youtube videos and it's great. I use another component called YoutubeExplode which I can query the media manifest using youtube id. The media manifest can extract the Video and Audio only URL which I pass to CrossMediaManager.Current.Play() to play. Video is ok but when playing audio only (MP4), value of duration is twice. I tested Xamarin iOS on iPhone, simulator and device.

Expected behavior

Audio only should have same duration as Video.

Reproduction steps

YoutubeClient client = new YoutubeClient(); // YoutubeExplode client

// You can use the youtube ids below // jgyl_LBdcxo // VbD_kBJc_gI // iSLwVaebsJg // 7m6_WcBYFIY

StreamManifest manifest = await client.Videos.Streams.GetManifestAsync (); var muxed = manifest .GetMuxedStreams() .OrderByDescending(v => v.VideoResolution.Height) .ToList() .FirstOrDefault();

string videoUrl = muxed != null ? muxed.Url : "";

var audio = manifest .GetAudioOnlyStreams() .Where(a => a.Container.Name.ToUpper() == "MP4") .OrderByDescending(a => a.Bitrate.BitsPerSecond) .ToList() .FirstOrDefault();

string audioUrl = audio != null ? audio.Url : "";

await CrossMediaManager.Current.Play(videoUrl); // Duration value here is correct await CrossMediaManager.Current.Play(audioUrl); // Duration value here is doubled/twice

Configuration

Xamarin latest iOS, iPhone

Version: 1.x

Platform: