public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Do any additional setup after loading the view.

            // First initialize FFmpeg dependencies

            MediaElement.FFmpegDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ffmpeg");

            // Create image view that will show each frame

            imageView = new NSImageView(new CoreGraphics.CGRect(
                                            (View.Bounds.Width - 640) / 2,
                                            (View.Bounds.Height - 480) / 2,
                                            640, 480))
            {
                Image = new NSImage(new NSUrl("https://github.com/unosquare/ffmediaelement/raw/master/Support/ffme.png"))
            };
            View.AddSubview(imageView);

            imageView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;

            // Create a player and start playing sample video

            var mediaElement = new MediaElement(imageView);
            var uri          = @"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4";
            var openTask     = mediaElement.Open(new Uri(uri));
        }
 public void PlayStream()
 {
     Application.Current.Dispatcher.Invoke(async() =>
     {
         await MediaElement.Open(new Uri(Channel.M3U8Address));
     });
 }
 public void ReloadStream()
 {
     Application.Current.Dispatcher.Invoke(async() =>
     {
         await MediaElement.Stop();
         await MediaElement.Close();
         await MediaElement.Open(new Uri(Channel.M3U8Address));
     });
 }
        public override Task <bool> LoadMedia(string filePath)
        {
            UnloadMedia();
            _loadTcs = null;
            _loadTcs = new TaskCompletionSource <bool>();

            //_mediaElement.Source = new Uri(filePath);
            _mediaElement.Open(new Uri(filePath));
            return(_loadTcs.Task);
        }
        public void PlayStream(string m3u8Address)
        {
            Application.Current.Dispatcher.Invoke(async() =>
            {
                try
                {
                    Debug.WriteLine(m3u8Address);

                    MediaElement = new MediaElement
                    {
                        Volume = .50
                    };
                    MediaElement.MediaOpening += OnMediaOpening;

                    await MediaElement.Open(new Uri(m3u8Address));
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                }
            });
        }
Esempio n. 6
0
 public static async Task Open(this MediaElement mediaElement, string filepath)
 {
     await mediaElement.Open(new Uri(filepath));
 }
Esempio n. 7
0
        private void StartScene()
        {
            if (openScene)
            {
                return;
            }

            if (closed)
            {
                openScene = true;
                closed    = false;

                try
                {
                    Scene sc = null;
                    lock (upscs)
                        sc = upscs[_num];

                    CurrentSceneFileName = sc.Name;

                    switch (MediaType)
                    {
                    case MediaTypeEnum.LOCAL_STREAM:
                        CurrentSceneFileName = new FileInfo(Uri).Directory.FullName + @"\" + sc.Name;
                        break;

                    case MediaTypeEnum.NETWORK_STREAM:
                        CurrentSceneFileName = CacheDirectory + sc.Name;
                        break;
                    }

                    curr_player = !curr_player;

                    if (String.IsNullOrEmpty(MediaElement.FileName) || !MediaElement.FileName.Contains(sc.Name))
                    {
                        MediaElement.Open(CurrentSceneFileName);
                        MediaElement.Play();
                    }
                    else
                    {
                        MediaElement.CurrentPosition = 0;
                        MediaElement.Play();
                    }

                    MediaElement.Volume = volume;
                    MediaElement.BringToFront();
                    MediaElement.AudioStream = 0;

                    buffering = false;
                    if (MediaBuffering != null)
                    {
                        MediaBuffering(this, EventArgs.Empty);
                    }

                    needPosition = 0L;

                    PreloadScene(sc);

                    if (_pos > 0)
                    {
                        MediaElement.CurrentPosition = (double)_pos / 1000.0;
                    }

                    if (_set_on_pause)
                    {
                        if (Mode == PlayerMode.Pause)
                        {
                            MediaElement.Pause();
                        }
                    }

                    if (ffprobe == null || MediaType == MediaTypeEnum.FLAT_FILE)
                    {
                        ffprobe = new Ffprobe(CurrentSceneFileName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex);
                }
                finally
                {
                    currentScene = _num;
                    openScene    = false;
                }
            }
        }
Esempio n. 8
0
 public async Task <bool> Play(File file) => await _media.Open(new Uri(file.Directory));