private async Task SetSource(AtomVideoSource source) { try { asset = await LoadAsset(source); playerItem = new AVPlayerItem(asset); player = new AVPlayer(playerItem); playerController = new AVPlayerViewController(); Control.AddSubview(playerController.View); playerController.Player = player; playerController.View.Frame = Control.Frame; player.Seek(CMTime.FromSeconds(1, 1000)); if (Element.IsPlaying) { player.Play(); } } catch (Exception ex) { AtomDevice.Instance.Log(ex); } }
private void SetVideoSource(AtomVideoSource source) { DisposeChildren(); if (source == null) { return; } Device.BeginInvokeOnMainThread(async() => await SetSource(source)); }
private Task <AVAsset> LoadAsset(AtomVideoSource source) { if (source.Url != null) { return(Task.FromResult(AVAsset.FromUrl(new NSUrl(source.Url)))); } if (source.FilePath != null) { return(Task.FromResult(AVAsset.FromUrl(new NSUrl(source.FilePath, false)))); } throw new NotImplementedException(); }