Ejemplo n.º 1
0
        public async Task SetMediaFile(IVLCMedia media)
        {
            var mrl_fromType = media.GetMrlAndFromType();

            LogHelper.Log("SetMRL: " + mrl_fromType.Item2);
            await PlayerInstanceReady.Task;

            if (Instance == null)
            {
                return;
            }
            var mediaVLC = new Media(Instance, mrl_fromType.Item2, mrl_fromType.Item1);

            MediaPlayer = new MediaPlayer(mediaVLC);
            LogHelper.Log("PLAYWITHVLC: MediaPlayer instance created");
            var em = MediaPlayer.eventManager();

            em.OnBuffering += EmOnOnBuffering;
            em.OnStopped   += EmOnOnStopped;
            em.OnPlaying   += OnPlaying;
            em.OnPaused    += OnPaused;
            if (TimeChanged != null)
            {
                em.OnTimeChanged += TimeChanged;
            }
            em.OnEndReached       += EmOnOnEndReached;
            em.OnEncounteredError += em_OnEncounteredError;
            em.OnLengthChanged    += em_OnLengthChanged;
            // todo: is there another way? sure there is.
            _isAudioMedia = media is TrackItem;
        }
Ejemplo n.º 2
0
        public async Task SetMediaFile(IMediaItem media)
        {
            Media vlcMedia = null;

            if (media.VlcMedia != null)
            {
                vlcMedia = media.VlcMedia;
            }
            else
            {
                var mrl_fromType = media.GetMrlAndFromType();
                LogHelper.Log("SetMRL: " + mrl_fromType.Item2);
                if (Instance == null)
                {
                    await Initialize();
                }
                await PlayerInstanceReady.Task;

                if (!PlayerInstanceReady.Task.Result)
                {
                    LogHelper.Log($"Couldn't play media {media.Name} as VLC failed to init");
                    return;
                }

                vlcMedia = new Media(Instance, mrl_fromType.Item2, mrl_fromType.Item1);
            }

            // Hardware decoding
            vlcMedia.addOption(!Locator.SettingsVM.HardwareAccelerationEnabled ? ":avcodec-hw=none" : ":avcodec-hw=d3d11va");
            vlcMedia.addOption(!Locator.SettingsVM.HardwareAccelerationEnabled ? ":avcodec-threads=0" : ":avcodec-threads=1");

            MediaPlayer = new MediaPlayer(vlcMedia);
            LogHelper.Log("PLAYWITHVLC: MediaPlayer instance created");
            MediaPlayer.outputDeviceSet(AudioClient.audioClient());
            SetEqualizer(Locator.SettingsVM.Equalizer);
            var em = MediaPlayer.eventManager();

            em.OnOpening   += Em_OnOpening;
            em.OnBuffering += EmOnOnBuffering;
            em.OnStopped   += EmOnOnStopped;
            em.OnPlaying   += OnPlaying;
            em.OnPaused    += OnPaused;
            if (TimeChanged != null)
            {
                em.OnTimeChanged += TimeChanged;
            }
            em.OnEndReached       += EmOnOnEndReached;
            em.OnEncounteredError += em_OnEncounteredError;
            em.OnLengthChanged    += em_OnLengthChanged;
        }
Ejemplo n.º 3
0
        public async Task SetMediaFile(IVLCMedia media)
        {
            var mrl_fromType = media.GetMrlAndFromType();
            LogHelper.Log("SetMRL: " + mrl_fromType.Item2);
            await PlayerInstanceReady.Task;
            if (Instance == null) return;
            var mediaVLC = new Media(Instance, mrl_fromType.Item2, mrl_fromType.Item1);

            MediaPlayer = new MediaPlayer(mediaVLC);
            LogHelper.Log("PLAYWITHVLC: MediaPlayer instance created");
            var em = MediaPlayer.eventManager();
            em.OnBuffering += EmOnOnBuffering;
            em.OnStopped += EmOnOnStopped;
            em.OnPlaying += OnPlaying;
            em.OnPaused += OnPaused;
            if (TimeChanged != null)
                em.OnTimeChanged += TimeChanged;
            em.OnEndReached += EmOnOnEndReached;
            em.OnEncounteredError += em_OnEncounteredError;
            em.OnLengthChanged += em_OnLengthChanged;
            // todo: is there another way? sure there is.
            _isAudioMedia = media is TrackItem;
        }
Ejemplo n.º 4
0
 public void SetNullMediaPlayer()
 {
     MediaPlayer = null;
 }
Ejemplo n.º 5
0
 public void SetNullMediaPlayer()
 {
     MediaPlayer = null;
 }