コード例 #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;
                 };
             }
         }
     }
 }
コード例 #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;
 }
コード例 #3
0
ファイル: MediaPlayer.cs プロジェクト: DrPandemic/EraParadox
        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;
        }
コード例 #4
0
 public static void Resume()
 {
     if (_song != null)
     {
         _song.Play();
         _mediaState = MediaState.Playing;
     }
 }
コード例 #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);
		}
コード例 #6
0
 public static void Play(Song song)
 {
     if (song != null)
     {
         _song        = song;
         _song.Volume = _volume;
         _song.Loop   = _looping;
         _song.Play();
         _mediaState = MediaState.Playing;
     }
 }
コード例 #7
0
ファイル: MediaPlayer.cs プロジェクト: ValXp/MonoGame
        public static void Play(Song song)
        {
			if ( song != null )
			{
				_song = song;
				_song.Volume = _volume;
				_song.Loop = _looping;
				_song.Play();
				_mediaState = MediaState.Playing;
			}
        }
コード例 #8
0
        private static void PlatformPlaySong(Song song)
        {
            if (_queue.ActiveSong == null)
            {
                return;
            }

            song.SetEventHandler(OnSongFinishedPlaying);

            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #11
0
ファイル: MediaPlayer.cs プロジェクト: liwq-net/SilverSprite
 public static void Play(Song song)
 {
     _song = song;
     song.SetRepeating(IsRepeating);
     song.Play(Volume);
 }
コード例 #12
0
ファイル: MediaPlayer.cs プロジェクト: 0x0ade/FNA-Legacy
 private static void PlaySong(Song song)
 {
     song.Volume = IsMuted ? 0.0f : Volume;
     song.Play();
     State = MediaState.Playing;
 }
コード例 #13
0
        private static void PlatformPlaySong(Song song)
        {
            if (_queue.ActiveSong == null)
                return;

            song.SetEventHandler(OnSongFinishedPlaying);

            song.Volume = _isMuted ? 0.0f : _volume;
            song.Play();
        }
コード例 #14
0
ファイル: MediaPlayer.cs プロジェクト: TheDuderist/MonoGame
 private static void PlaySong(Song song)
 {
     song.Volume = IsMuted ? 0.0f : Volume;
     song.Play();
     State = MediaState.Playing;
 }
コード例 #15
0
ファイル: MediaPlayer.cs プロジェクト: tanis2000/FEZ
 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;
 }
コード例 #16
0
ファイル: MediaPlayer.cs プロジェクト: valsavva/dynacat
		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;
		}