Exemple #1
0
 public static void Play <T>(T obj)
 {
     if (typeof(T) == typeof(Song))
     {
         Song song = obj as Song;
         if (currentSong == song)
         {
             if (!isPlaying)
             {
                 song.Resume();
             }
         }
         else
         {
             song.SetLoop(IsRepeating);
             currentSong = song;
             if (song.Loaded)
             {
                 song.Play();
                 isPlaying = true;
             }
             else
             {
                 contentManager.OnAllResourceLoaded = () =>
                 {
                     song.Play();
                     isPlaying = true;
                 };
             }
         }
     }
 }
Exemple #2
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;
 }
Exemple #3
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;
        }
Exemple #4
0
 public static void Resume()
 {
     if (_song != null)
     {
         _song.Play();
         _mediaState = MediaState.Playing;
     }
 }
Exemple #5
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);
		}
Exemple #6
0
 public static void Play(Song song)
 {
     if (song != null)
     {
         _song        = song;
         _song.Volume = _volume;
         _song.Loop   = _looping;
         _song.Play();
         _mediaState = MediaState.Playing;
     }
 }
Exemple #7
0
        public static void Play(Song song)
        {
			if ( song != null )
			{
				_song = song;
				_song.Volume = _volume;
				_song.Loop = _looping;
				_song.Play();
				_mediaState = MediaState.Playing;
			}
        }
Exemple #8
0
        private static void PlatformPlaySong(Song song)
        {
            if (_queue.ActiveSong == null)
            {
                return;
            }

            song.SetEventHandler(OnSongFinishedPlaying);

            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
        }
        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;
        }
Exemple #10
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;
        }
Exemple #11
0
 public static void Play(Song song)
 {
     _song = song;
     song.SetRepeating(IsRepeating);
     song.Play(Volume);
 }
Exemple #12
0
 private static void PlaySong(Song song)
 {
     song.Volume = IsMuted ? 0.0f : Volume;
     song.Play();
     State = MediaState.Playing;
 }
        private static void PlatformPlaySong(Song song)
        {
            if (_queue.ActiveSong == null)
                return;

            song.SetEventHandler(OnSongFinishedPlaying);

            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
        }
Exemple #14
0
 private static void PlaySong(Song song)
 {
     song.Volume = IsMuted ? 0.0f : Volume;
     song.Play();
     State = MediaState.Playing;
 }
Exemple #15
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;
 }
Exemple #16
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;
		}