Ejemplo n.º 1
0
        private static void StartNewSong(Song song, TimeSpan?startPosition)
        {
            lock (_volumeLock)
            {
                if (_volumeController != null)
                {
                    _volumeController.Dispose();
                    _volumeController = null;
                }
            }

            _currentSong = song;

            //We need to start playing from 0, then seek the stream when the topology is ready, otherwise the song doesn't play.
            if (startPosition.HasValue)
            {
                _desiredPosition = PositionVariantFor(startPosition.Value);
            }
            _session.SetTopology(SessionSetTopologyFlags.Immediate, song.Topology);

            StartSession(PositionBeginning);

            // The volume service won't be available until the session topology
            // is ready, so we now need to wait for the event indicating this
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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.
            _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);
        }
Ejemplo n.º 4
0
        private static void OnTopologyReady()
        {
            IntPtr volumeObjectPtr;

            MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
            _volumeController = CppObject.FromPointer <AudioStreamVolume>(volumeObjectPtr);

            SetChannelVolumes();
        }
Ejemplo n.º 5
0
 private static void PlatformStop()
 {
     _session.ClearTopologies();
     _session.Stop();
     _session.Close();
     _volumeController.Dispose();
     _volumeController = null;
     _clock.Dispose();
     _clock = null;
 }
Ejemplo n.º 6
0
        private void PlatformSpecificProcessMusicReady()
        {
            // The topology of the MediaSession is ready.

            if (!currentMusic.IsDisposed) // disposal of the music can happen between the call to Play and its ready-to-play state notification
            {
                // Query the Volume interface associated to the new topology
                IntPtr volumeObj;
                MediaFactory.GetService(mediaSession, MediaServiceKeys.StreamVolume, streamAudioVolumeGuid, out volumeObj);
                streamVolume = new AudioStreamVolume(volumeObj);
            }
        }
Ejemplo n.º 7
0
        private void OnTopologyReady()
        {
            if (_session.IsDisposed)
            {
                return;
            }

            // Get the volume interface.
            IntPtr volumeObjectPtr;

            MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
            _volumeController = CppObject.FromPointer <AudioStreamVolume>(volumeObjectPtr);

            SetChannelVolumes();
        }
Ejemplo n.º 8
0
        private static void OnTopologyReady()
        {
            IntPtr volumeObjectPtr;

            MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
            _volumeController = CppObject.FromPointer <AudioStreamVolume>(volumeObjectPtr);

            SetChannelVolumes();

            if (_desiredPosition.HasValue)
            {
                StartSession(_desiredPosition.Value);
                _desiredPosition = null;
            }
        }
Ejemplo n.º 9
0
 private void PlatformStop()
 {
     _session.ClearTopologies();
     _session.Stop();
     _session.Close();
     if (_volumeController != null)
     {
         _volumeController.Dispose();
         _volumeController = null;
     }
     if (_clock != null)
     {
         _clock.Dispose();
     }
     _clock = null;
 }
Ejemplo n.º 10
0
        private void OnTopologyReady()
        {
            if (_session.IsDisposed)
                return;

            try {
                // Get the volume interface.
                IntPtr volumeObjectPtr;
                MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
                _volumeController = CppObject.FromPointer<AudioStreamVolume>(volumeObjectPtr);

                SetChannelVolumes();
            }
            catch (Exception e) {
                _volumeController = null;
            }
        }
Ejemplo n.º 11
0
        private static void StartNewSong(Song song)
        {
            if (_volumeController != null)
            {
                _volumeController.Dispose();
                _volumeController = null;
            }

            _currentSong = song;

            _session.SetTopology(SessionSetTopologyFlags.Immediate, song.Topology);

            StartSession(PositionBeginning);

            // The volume service won't be available until the session topology
            // is ready, so we now need to wait for the event indicating this
        }
Ejemplo n.º 12
0
        private void ProcessPlayerClosed()
        {
            // The session finished to close, we have to dispose all related object.
            currentMusic = null;

            mediaSessionCallback.Dispose();

            if (mediaSource != null)
            {
                mediaSource.Shutdown();
            }
            if (mediaSession != null)
            {
                mediaSession.Shutdown();
            }

            if (streamVolume != null)
            {
                streamVolume.Dispose();
            }
            if (mediaSource != null)
            {
                mediaSource.Dispose();
            }
            if (topology != null)
            {
                topology.Dispose();
            }
            if (mediaSession != null)
            {
                mediaSession.Dispose();
            }
            if (mediaInputByteStream != null)
            {
                mediaInputByteStream.Dispose();
            }

            topology             = null;
            streamVolume         = null;
            mediaSession         = null;
            mediaSource          = null;
            mediaInputByteStream = null;
            mediaSessionCallback = null;
            isMusicPlayerReady   = false;
        }
Ejemplo n.º 13
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);
        }
        private void PlatformSpecificProcessMusicReady()
        {
            // The topology of the MediaSession is ready.

            if (!currentMusic.IsDisposed) // disposal of the music can happen between the call to Play and its ready-to-play state notification
            {
                // Query the Volume interface associated to the new topology
                IntPtr volumeObj;
                MediaFactory.GetService(mediaSession, MediaServiceKeys.StreamVolume, streamAudioVolumeGuid, out volumeObj);
                streamVolume = new AudioStreamVolume(volumeObj);
            }
        }
Ejemplo n.º 15
0
        private static void StartNewSong(Song song)
        {
            if (_volumeController != null)
            {
                _volumeController.Dispose();
                _volumeController = null;
            }

            _currentSong = song;

            _session.SetTopology(SessionSetTopologyFlags.Immediate, song.Topology);

            StartSession(PositionBeginning);

            // The volume service won't be available until the session topology
            // is ready, so we now need to wait for the event indicating this
        }
Ejemplo n.º 16
0
 private void PlatformStop()
 {
     _session.ClearTopologies();
     _session.Stop();
     _session.Close();
     if (_volumeController != null)
     {
         _volumeController.Dispose();
         _volumeController = null;
     }
     _clock.Dispose();
     _clock = null;
 }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        private static void OnTopologyReady()
        {
            IntPtr volumeObjectPtr;
            MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
            _volumeController = CppObject.FromPointer<AudioStreamVolume>(volumeObjectPtr);

            SetChannelVolumes();
        }
        private void ProcessPlayerClosed()
        {
            // The session finished to close, we have to dispose all related object.
            currentMusic = null;

            mediaSessionCallback.Dispose();

            if (mediaSource != null) mediaSource.Shutdown();
            if (mediaSession != null) mediaSession.Shutdown();

            if (streamVolume != null) streamVolume.Dispose();
            if (mediaSource != null) mediaSource.Dispose();
            if (topology != null) topology.Dispose();
            if (mediaSession != null) mediaSession.Dispose();
            if (mediaInputByteStream != null) mediaInputByteStream.Dispose();

            topology = null;
            streamVolume = null;
            mediaSession = null;
            mediaSource = null;
            mediaInputByteStream = null;
            mediaSessionCallback = null;
            isMusicPlayerReady = false;
        }
Ejemplo n.º 20
0
        private static void StartNewSong(Song song, TimeSpan? startPosition)
        {
            if (_volumeController != null)
            {
                _volumeController.Dispose();
                _volumeController = null;
            }

            _currentSong = song;

            //We need to start playing from 0, then seek the stream when the topology is ready, otherwise the song doesn't play.
            if (startPosition.HasValue)
                _desiredPosition = PositionVariantFor(startPosition.Value);
            _session.SetTopology(SessionSetTopologyFlags.Immediate, song.Topology);

            StartSession(PositionBeginning);

            // The volume service won't be available until the session topology
            // is ready, so we now need to wait for the event indicating this
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        private static void OnTopologyReady()
        {
            IntPtr volumeObjectPtr;
            MediaFactory.GetService(_session, MediaServiceKeys.StreamVolume, AudioStreamVolumeGuid, out volumeObjectPtr);
            _volumeController = CppObject.FromPointer<AudioStreamVolume>(volumeObjectPtr);

            SetChannelVolumes();

            if (_desiredPosition.HasValue)
            {
                StartSession(_desiredPosition.Value);
                _desiredPosition = null;
            }
        }