예제 #1
0
        private async void TryToUseFFmpegURI()
        {
            try
            {
                // Set FFmpeg specific options. List of options can be found in https://www.ffmpeg.org/ffmpeg-protocols.html

                // Below are some sample options that you can set to configure RTSP streaming
                // Config.FFmpegOptions.Add("rtsp_flags", "prefer_tcp");
                // Config.FFmpegOptions.Add("stimeout", 100000);

                // Instantiate FFmpegInteropMSS using the URI
                VideoBox.Stop();
                ffmpegMss = await FFmpegInteropMSS.CreateFromUriAsync(inputURI);

                var source = ffmpegMss.CreateMediaPlaybackItem();

                // Pass MediaStreamSource to Media Element
                VideoBox.SetPlaybackSource(source);
            }
            catch (Exception ex)
            {
                ShowDialog.DisplayErrorMessage(ex.Message);
            }


            //try
            //{
            //    // Set FFmpeg specific options. List of options can be found in https://www.ffmpeg.org/ffmpeg-protocols.html
            //    PropertySet options = new PropertySet();

            //    // Below are some sample options that you can set to configure RTSP streaming
            //    // options.Add("rtsp_flags", "prefer_tcp");
            //    // options.Add("stimeout", 100000);

            //    // Instantiate FFmpegInteropMSS using the URI
            //    ffmpegMss = await FFmpegInteropMSS.CreateFromUriAsync(inputURI);
            //    if (ffmpegMss != null)
            //    {
            //        MediaStreamSource mss = ffmpegMss.GetMediaStreamSource();

            //        if (mss != null)
            //        {
            //            // Pass MediaStreamSource to Media Element
            //            VideoBox.Source = MediaSource.CreateFromMediaStreamSource(mss);
            //        }
            //        else
            //        {
            //            ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //        }
            //    }
            //    else
            //    {
            //        ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    ShowDialog.DisplayErrorMessage(ex.Message);
            //}
        }
예제 #2
0
        private void TryToLoadAndPlay(string uri)
        {
            inputURI = uri;

            VideoBox.SetPlaybackSource(MediaSource.CreateFromUri(new Uri(inputURI)));
            VideoBox.Play();

            //VideoBox.MediaPlayer.MediaFailed += URIMediaFailed;
        }
예제 #3
0
        private async void picker_Click(object sender, RoutedEventArgs e)
        {
            inputFile = await OpenFile.LoadFileAsync();

            if (inputFile != null)
            {
                VideoBox.SetPlaybackSource(MediaSource.CreateFromStorageFile(inputFile));
                //VideoBox.MediaPlayer.RealTimePlayback = true;
                VideoBox.Play();

                //VideoBox.MediaPlayer.MediaFailed += LocalMediaFailed;
            }
        }
예제 #4
0
        private async void TryToLoadAndPlay(StorageFile file)
        {
            inputFile = file;
            var stream = await inputFile.OpenAsync(FileAccessMode.Read);

            VideoBox.SetPlaybackSource(MediaSource.CreateFromStorageFile(inputFile));

            VideoBox.Play();
            //VideoBox.MediaPlayer.RealTimePlayback = true;
            //VideoBox.MediaPlayer.Play();
            MediaTitleBlock.Text = inputFile.DisplayName;

            //VideoBox.MediaPlayer.MediaFailed += LocalMediaFailed;
        }
예제 #5
0
        private async void TryToUseFFmpegLocal()
        {
            if (inputFile != null)
            {
                VideoBox.Stop();

                // Open StorageFile as IRandomAccessStream to be passed to FFmpegInteropMSS
                IRandomAccessStream readStream = await inputFile.OpenAsync(FileAccessMode.Read);

                try
                {
                    // Instantiate FFmpegInteropMSS using the opened local file stream
                    ffmpegMss = await FFmpegInteropMSS.CreateFromStreamAsync(readStream);

                    if (ffmpegMss != null)
                    {
                        playbackItem = ffmpegMss.CreateMediaPlaybackItem();

                        // Pass MediaStreamSource to Media Element
                        VideoBox.SetPlaybackSource(playbackItem);
                    }
                    else
                    {
                        ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
                    }
                }
                catch (Exception ex)
                {
                    ShowDialog.DisplayErrorMessage(ex.Message);
                }
            }

            //try
            //{
            //    IRandomAccessStream readStream = await inputFile.OpenAsync(FileAccessMode.Read);

            //    ffmpegMss = await FFmpegInteropMSS.CreateFromStreamAsync(readStream);

            //    if (ffmpegMss != null)
            //    {
            //        MediaStreamSource mss = ffmpegMss.GetMediaStreamSource();

            //        if (mss != null)
            //        {
            //            mss.BufferTime = TimeSpan.Zero;
            //            sender.Source = MediaSource.CreateFromMediaStreamSource(mss);
            //            sender.RealTimePlayback = true;
            //            sender.Play();
            //        }
            //        else
            //        {
            //            ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //        }
            //    }
            //    else
            //    {
            //        ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    ShowDialog.DisplayErrorMessage(ex.Message);
            //}
        }