Пример #1
0
        private static void PlatformPlaySong(Song song)
        {
            // Cleanup the last song first.
            if (State != MediaState.Stopped)
            {
                _session.Stop();
                _session.ClearTopologies();
                _session.Close();
                _volumeController.Dispose();
                _clock.Dispose();
            }

            // Set the new song.
            _session.SetTopology(SessionSetTopologyFlags.Immediate, song.Topology);

            // Get the volume interface.
            _volumeController = CppObject.FromPointer <AudioStreamVolume>(MediaPlayer.GetVolumeObj(_session));
            SetChannelVolumes();

            // Get the clock.
            _clock = _session.Clock.QueryInterface <PresentationClock>();

            //create the callback if it hasn't been created yet
            if (_callback == null)
            {
                _callback = new Callback();
                _session.BeginGetEvent(_callback, null);
            }

            // Start playing.
            var varStart = new Variant();

            _session.Start(null, varStart);
        }
Пример #2
0
        private void PlatformPlay()
        {
            // Cleanup the last song first.
            if (State != MediaState.Stopped)
            {
                _session.Stop();
                _session.ClearTopologies();
                _session.Close();
                if (_volumeController != null)
                {
                    _volumeController.Dispose();
                    _volumeController = null;
                }
                _clock.Dispose();
            }

            //create the callback if it hasn't been created yet
            if (_callback == null)
            {
                _callback = new Callback(this);
                _session.BeginGetEvent(_callback, null);
            }

            // Set the new song.
            _session.SetTopology(SessionSetTopologyFlags.Immediate, _currentVideo.Topology);

            // Get the clock.
            _clock = _session.Clock.QueryInterface <PresentationClock>();

            // Start playing.
            var varStart = new Variant();

            _session.Start(null, varStart);
        }
Пример #3
0
        private static void PlatformPlaySong(Song song)
        {
            // Cleanup the last song first.
            if (State != MediaState.Stopped)
            {
                _session.Stop();
                _session.ClearTopologies();
                _session.Close();
                _volumeController.Dispose();
                _clock.Dispose();
            }

            // Set the new song.
            _session.SetTopology(SessionSetTopologyFlags.Immediate, song.Topology);

            // Get the volume interface.
            IntPtr volumeObj;


            try
            {
                MediaFactory.GetService(_session, MRPolicyVolumeService, SimpleAudioVolumeGuid, out volumeObj);
            }
            catch
            {
                MediaFactory.GetService(_session, MRPolicyVolumeService, SimpleAudioVolumeGuid, out volumeObj);
            }


            _volumeController              = CppObject.FromPointer <SimpleAudioVolume>(volumeObj);
            _volumeController.Mute         = _isMuted;
            _volumeController.MasterVolume = _volume;

            // Get the clock.
            _clock = _session.Clock.QueryInterface <PresentationClock>();

            //create the callback if it hasn't been created yet
            if (_callback == null)
            {
                _callback = new Callback();
                _session.BeginGetEvent(_callback, null);
            }

            // Start playing.
            var varStart = new Variant();

            _session.Start(null, varStart);
        }
Пример #4
0
        public static void Stop()
        {
            if (State == MediaState.Stopped)
            {
                return;
            }

#if WINDOWS_MEDIA_ENGINE
            _mediaEngineEx.Source = null;
#elif WINDOWS_MEDIA_SESSION
            _session.ClearTopologies();
            _session.Stop();
            _volumeController.Dispose();
            _volumeController = null;
            _clock.Dispose();
            _clock = null;
#else
            // Loop through so that we reset the PlayCount as well
            foreach (var song in Queue.Songs)
            {
                _queue.ActiveSong.Stop();
            }
#endif
            State = MediaState.Stopped;
        }
Пример #5
0
 public override void Dispose()
 {
     FLLog.Info("Video", "Closing Windows Media Foundation backend");
     if (session != null)
     {
         session.ClearTopologies();
         session.Stop();
         session.Close();
         session.Dispose();
     }
     if (topology != null)
     {
         topology.Dispose();
     }
     if (videoSampler != null)
     {
         videoSampler.Dispose();
     }
     if (clock != null)
     {
         clock.Dispose();
     }
     if (_texture != null)
     {
         _texture.Dispose();
     }
     if (cb != null)
     {
         cb.Dispose();
     }
 }
Пример #6
0
 private void PlatformStop()
 {
     _session.ClearTopologies();
     _session.Stop();
     _session.Close();
     _volumeController.Dispose();
     _volumeController = null;
     _clock.Dispose();
     _clock = null;
 }
Пример #7
0
        private void PlatformPlay()
        {
            // Cleanup the last song first.
            if (State != MediaState.Stopped)
            {
                _session.Stop();
                _session.ClearTopologies();
                _session.Close();
                if (_volumeController != null)
                {
                    _volumeController.Dispose();
                    _volumeController = null;
                }
                _clock.Dispose();
            }

            //create the callback if it hasn't been created yet
            if (_callback == null)
            {
                _callback = new Callback(this);
                _session.BeginGetEvent(_callback, null);
            }

            // Set the new song.
            _session.SetTopology(SessionSetTopologyFlags.Immediate, _currentVideo.Topology);

            // Get the clock.
            _clock = _session.Clock.QueryInterface <PresentationClock>();

            // Start playing.
            var varStart = new Variant();

            _session.Start(null, varStart);

            // we need to dispose of the old texture if we have one
            if (_videoCache != null)
            {
                _videoCache.Dispose();
            }
            // Create cached texture
            _videoCache = new Texture2D(_graphicsDevice, _currentVideo.Width, _currentVideo.Height, false, SurfaceFormat.Bgr32);
        }
 public override void Dispose()
 {
     FLLog.Info("Video", "Closing Windows Media Foundation backend");
     if (session != null)
     {
         session.Stop();
         session.ClearTopologies();
         //Sample grabber thread works asynchronously (as task), so we need give him a time, to understand, that session is closed
         //minimal time to wait: 33 ms (1000 ms / 30 fps), but I decide to use a little more
         System.Threading.Thread.Sleep(100);
         session.Close();
         session.Dispose();
         session = null;
     }
     if (topology != null)
     {
         topology.Dispose();
         topology = null;
     }
     if (videoSampler != null)
     {
         videoSampler.Dispose();
         videoSampler = null;
     }
     if (clock != null)
     {
         clock.Dispose();
         clock = null;
     }
     if (_texture != null)
     {
         _texture.Dispose();
         _texture = null;
     }
     if (cb != null)
     {
         cb.Dispose();
         cb = null;
     }
 }