public async Task Seek(TimeSpan position) { int msec = Convert.ToInt32(position.TotalMilliseconds); VideoViewCanvas.SeekTo(msec); lastPosition = VideoViewCanvas.CurrentPosition; await Task.CompletedTask; }
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 Seek(TimeSpan position) { VideoViewCanvas.SeekTo(Convert.ToInt32(position.TotalMilliseconds)); await Task.CompletedTask; }