private async Task RefreshLeoPlayer() { if (_HLSUri == null) { return; } ClearLeoPlayer(); var streamAsyncUri = _HLSUri.Replace("master.m3u8", "stream_sync.json"); var playSetupRes = await HohoemaApp.NiconicoContext.HttpClient.GetAsync(new Uri(streamAsyncUri)); try { _Mss = FFmpegInterop.FFmpegInteropMSS.CreateFFmpegInteropMSSFromUri(_HLSUri, false, false); _MediaSource = MediaSource.CreateFromMediaStreamSource(_Mss.GetMediaStreamSource()); HohoemaApp.MediaPlayer.Source = _MediaSource; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } base.OnNavigatedTo(e); try { rtspAddress = e.Parameter as string; UnknownCameraViewModel.RtspAddress = rtspAddress; this.ffmpeg = await FFmpegInterop.FFmpegInteropMSS.CreateFromUriAsync(rtspAddress); MediaStreamSource streamSource = ffmpeg.GetMediaStreamSource(); this.MediaElement.SetMediaStreamSource(streamSource); this.MediaElement.Play(); } catch (System.Runtime.InteropServices.COMException ex) { ContentDialog dialog = new ContentDialog(); dialog.Content = ex.Message; dialog.CloseButtonText = "OK"; dialog.CloseButtonStyle = (Style)this.Resources["buttonStyle"]; await dialog.ShowAsync(); } }
private void ClearLeoPlayer() { if (HohoemaApp.MediaPlayer.Source == _MediaSource) { HohoemaApp.MediaPlayer.Source = null; } _Mss?.Dispose(); _Mss = null; _MediaSource?.Dispose(); _MediaSource = null; }
private async void AddCamera() { try { ffmpeg = await FFmpegInterop.FFmpegInteropMSS.CreateFromUriAsync(RtspAddressTextBox.Text); await CamerasViewModel.AddCamera(newCamera); HideFlyout(); } catch (System.Runtime.InteropServices.COMException) { ShowContentDialog("Can not add this camera"); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } base.OnNavigatedTo(e); Camera camera = e.Parameter as Camera; this.CameraViewModel = new CameraViewModel(camera); this.GoBackCommand = new ButtonCommand(new Action(GoBack)); this.AddToFavouritesCommand = new ButtonCommand(new Action(this.AddToFavourites)); this.RemoveFromFavouritesCommand = new ButtonCommand(new Action(this.RemoveFromFavourites)); if (this.CameraViewModel.CanExecuteAddToFavouritesCommand()) { this.AddToFavouritesButton.Command = this.AddToFavouritesCommand; } else { this.AddToFavouritesButton.Command = this.RemoveFromFavouritesCommand; this.HeartIcon.Glyph = "\xEB52"; } try { this.ffmpeg = await FFmpegInterop.FFmpegInteropMSS.CreateFromUriAsync(camera.RtspAddress); MediaStreamSource streamSource = ffmpeg.GetMediaStreamSource(); this.MediaElement.SetMediaStreamSource(streamSource); this.MediaElement.Play(); CameraViewModel.AddToRecent(); } catch (System.Runtime.InteropServices.COMException exception) { ShowContentDialog(exception.Message); GoBack(); } }
private async Task ClearLeoPlayer() { await HohoemaApp.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { if (MediaPlayer.Source == _MediaSource) { MediaPlayer.Source = null; CloseLive?.Invoke(this); } _Mss?.Dispose(); _Mss = null; _MediaSource?.Dispose(); _MediaSource = null; _AdaptiveMediaSource?.Dispose(); _AdaptiveMediaSource = null; }); }
private async Task ClearLeoPlayer() { _UIScheduler.Schedule(() => { if (MediaPlayer.Source == _MediaSource) { MediaPlayer.Source = null; CloseLive?.Invoke(this); } _Mss?.Dispose(); _Mss = null; _MediaSource?.Dispose(); _MediaSource = null; _AdaptiveMediaSource?.Dispose(); _AdaptiveMediaSource = null; }); await Task.CompletedTask; }