public async Task Play(IMediaFile mediaFile = null) { if (!IsReadyRendering) { //Android ViewRenderer might not initialize Control yet return; } if (isPlayerReady == false) { //await Task.Delay(100); Init(); isPlayerReady = true; } if (mediaFile == null || (mediaFile != null && string.IsNullOrEmpty(mediaFile.Url))) { return; } if (mediaFile != null && CurrentFile != mediaFile) { CurrentFile = mediaFile; currentUri = Android.Net.Uri.Parse(mediaFile.Url); VideoViewCanvas.StopPlayback(); //VideoViewCanvas.Suspend(); Status = MediaPlayerStatus.Stopped; } if (Status == MediaPlayerStatus.Paused) { //We are simply paused so just continue VideoViewCanvas.SeekTo(lastPosition); VideoViewCanvas.Start(); Status = MediaPlayerStatus.Playing; return; } try { Status = MediaPlayerStatus.Buffering; VideoViewCanvas.SetVideoURI(currentUri, RequestHeaders); } catch (System.Exception ex) { OnMediaFailed(new MediaFailedEventArgs(ex.Message, ex)); Status = MediaPlayerStatus.Stopped; } }
public async Task Stop() { VideoViewCanvas.StopPlayback(); Status = MediaPlayerStatus.Stopped; await Task.CompletedTask; }
public async Task Stop() { VideoViewCanvas.StopPlayback(); }