Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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());
            }
        }
Exemplo n.º 3
0
        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();
            }
        }