コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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
        }
コード例 #4
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);
        }
コード例 #5
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
        }
コード例 #6
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;
        }