Ejemplo n.º 1
0
 private static void PlaySong(Song song)
 {
     song.SetEventHandler(new Song.FinishedPlayingHandler(MediaPlayer.OnSongFinishedPlaying));
     song.Volume = MediaPlayer._isMuted ? 0.0f : MediaPlayer._volume;
     song.Play();
     MediaPlayer.State = MediaState.Playing;
 }
Ejemplo n.º 2
0
        private static void PlaySong(Song song)
        {
#if WINDOWS_MEDIA_ENGINE
            _mediaEngineEx.Source = song.FilePath;
            _mediaEngineEx.Load();
            _mediaEngineEx.Play();
#elif WINDOWS_MEDIA_SESSION
            // Cleanup the last song first.
            if (State != MediaState.Stopped)
            {
                _session.Stop();
                _volumeController.Dispose();
                _clock.Dispose();
            }

            // Set the new song.
            _session.SetTopology(0, song.GetTopology());

            // Get the volume interface.
            IntPtr volumeObj;


            try
            {
                MediaFactory.GetService(_session, MRPolicyVolumeService, SimpleAudioVolumeGuid, out volumeObj);
            }
            catch (Exception e)
            {
                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>();

            // Start playing.
            var varStart = new Variant();
            _session.Start(null, varStart);
#elif WINDOWS_PHONE
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                _mediaElement.Source = new Uri(song.FilePath, UriKind.Relative);
                _mediaElement.Play();

                // Ensure only one subscribe
                _mediaElement.MediaEnded -= OnSongFinishedPlaying;
                _mediaElement.MediaEnded += OnSongFinishedPlaying;
            });
#else
            song.SetEventHandler(OnSongFinishedPlaying);
            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
#endif
            State = MediaState.Playing;
        }
Ejemplo n.º 3
0
		private static void PlatformPlaySong(Song song, TimeSpan? startPosition)
		{
			if (_queue.ActiveSong == null)
				return;

			song.SetEventHandler(OnSongFinishedPlaying);

			song.Volume = _isMuted ? 0.0f : _volume;
			song.Play(startPosition);
		}
Ejemplo n.º 4
0
        private static void PlatformPlaySong(Song song)
        {
            if (_queue.ActiveSong == null)
            {
                return;
            }

            song.SetEventHandler(OnSongFinishedPlaying);

            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
        }
Ejemplo n.º 5
0
        private static void PlaySong(Song song)
        {
#if WINRT
            var folder    = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
            var path      = folder + "\\" + song.FilePath;
            var uri       = new Uri(path);
            var converted = uri.AbsoluteUri;

            _mediaEngineEx.Source = converted;
            _mediaEngineEx.Load();
            _mediaEngineEx.Play();
#else
            song.SetEventHandler(OnSongFinishedPlaying);
            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
#endif
            State = MediaState.Playing;
        }
Ejemplo n.º 6
0
        private static void PlaySong(Song song)
        {
#if WINDOWS_MEDIA_ENGINE
            _mediaEngineEx.Source = song.FilePath;
            _mediaEngineEx.Load();
            _mediaEngineEx.Play();
#elif WINDOWS_MEDIA_SESSION
            // Cleanup the last song first.
            if (State != MediaState.Stopped)
            {
                _session.Stop();
                _volumeController.Dispose();
                _clock.Dispose();
            }

            // Set the new song.
            _session.SetTopology(0, song.GetTopology());

            // Get the volume interface.
            IntPtr volumeObj;
            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>();

            // Start playing.
            var varStart = new Variant();
            _session.Start(null, varStart);
#else
            song.SetEventHandler(OnSongFinishedPlaying);
            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
#endif
            State = MediaState.Playing;
        }
Ejemplo n.º 7
0
        private static void PlatformPlaySong(Song song)
        {
            if (_queue.ActiveSong == null)
                return;

            song.SetEventHandler(OnSongFinishedPlaying);

            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
        }
Ejemplo n.º 8
0
 private static void PlaySong(Song song)
 {
   song.SetEventHandler(new Song.FinishedPlayingHandler(MediaPlayer.OnSongFinishedPlaying));
   song.Volume = MediaPlayer._isMuted ? 0.0f : MediaPlayer._volume;
   song.Play();
   MediaPlayer.State = MediaState.Playing;
 }
Ejemplo n.º 9
0
		private static void PlaySong(Song song)
		{
#if WINRT
			var folder = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
			var path = folder + "\\" + song.FilePath;
			var uri = new Uri(path);
			var converted = uri.AbsoluteUri;
			
			_mediaEngineEx.Source = converted;            
			_mediaEngineEx.Load();
			_mediaEngineEx.Play();
			
#else
			song.SetEventHandler(OnSongFinishedPlaying);			
			song.Volume = _isMuted ? 0.0f : _volume;
			song.Play();
#endif
			State = MediaState.Playing;
		}