3 #if SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME 
    5 using SharpDX.MediaFoundation;
 
    6 using SharpDX.Multimedia;
 
    8 namespace SiliconStudio.
Paradox.Audio
 
   10     partial class AudioEngine
 
   12         private MediaEngine mediaEngine;
 
   13         private MediaEngineEx mediaEngineEx;
 
   15         private void PlatformSpecificInit()
 
   19                                                                 AudioCategory = AudioStreamCategory.GameEffects })
 
   21                 var creationFlags = MediaEngineCreateFlags.None;
 
   22 #if SILICONSTUDIO_PLATFORM_WINDOWS_STORE 
   24                 creationFlags |= MediaEngineCreateFlags.AudioOnly;
 
   26                 using (var factory = 
new MediaEngineClassFactory())
 
   27                     mediaEngine = 
new MediaEngine(factory, attributes, creationFlags, OnMediaEngineEvent);
 
   29                 mediaEngineEx = mediaEngine.QueryInterface<MediaEngineEx>();
 
   33         private void PlatformSpecificDispose()
 
   35             mediaEngine.Shutdown();
 
   36             mediaEngine.Dispose();
 
   39         private void ResetMusicPlayer()
 
   43             isMusicPlayerReady = 
false;
 
   48         private void RestartCurrentMusic()
 
   50             mediaEngine.CurrentTime = 0;
 
   53         private void StartCurrentMusic()
 
   58         private void UpdateMusicVolume()
 
   60             mediaEngine.Volume = currentMusic.Volume;
 
   63         private void StopCurrentMusic()
 
   66             RestartCurrentMusic();
 
   69         private void PauseCurrentMusic()
 
   74         private void LoadNewMusic(SoundMusic lastPlayRequestMusicInstance)
 
   76             currentMusic = lastPlayRequestMusicInstance;
 
   78             mediaEngineEx.SetSourceFromByteStream(
new ByteStream(currentMusic.Stream), 
"MP3");
 
   81         private struct MediaEngineErrorCodes
 
   83             public long Parameter1;
 
   84             public int Parameter2;
 
   86             public MediaEngineErrorCodes(
long param1, 
int param2)
 
   93         private void OnMediaEngineEvent(MediaEngineEvent mediaEvent, 
long param1, 
int param2)
 
   97                 case MediaEngineEvent.LoadedMetadata:
 
   99                 case MediaEngineEvent.CanPlay:
 
  100                     musicMediaEvents.Enqueue(
new SoundMusicEventNotification(SoundMusicEvent.ReadyToBePlayed, null));
 
  102                 case MediaEngineEvent.Ended:
 
  103                     musicMediaEvents.Enqueue(
new SoundMusicEventNotification(SoundMusicEvent.EndOfTrackReached, null));
 
  105                 case MediaEngineEvent.Error:
 
  106                     musicMediaEvents.Enqueue(
new SoundMusicEventNotification(SoundMusicEvent.ErrorOccurred, 
new MediaEngineErrorCodes(param1, param2)));
 
  111         private void ProcessMusicError(SoundMusicEventNotification eventNotification)
 
  113             if (eventNotification.Event == SoundMusicEvent.ErrorOccurred)
 
  115                 var errorCodes = (MediaEngineErrorCodes) eventNotification.EventData;
 
  117                 if (errorCodes.Parameter1 == (
long)MediaEngineErr.SourceNotSupported)
 
  119                     if(currentMusic!=null)
 
  122                         throw new AudioSystemInternalException(
"Audio Engine is in an unconsistant state. CurrentMusic is null while Error on Unsupported media was reached.");
 
  124                     throw new InvalidOperationException(
"The data format of the source music file is not valid.");
 
  127                 throw new AudioSystemInternalException(
"An unhandled exception happened in media engine asynchronously. Error info [param1="+errorCodes.Parameter1+
", param2="+errorCodes.Parameter2+
"].");
 
  131         private void ProcessMusicMetaData()
 
  133             throw new System.NotImplementedException();
 
  136         private void ProcessPlayerClosed()
 
  138             throw new System.NotImplementedException();
 
  141         private void PlatformSpecificProcessMusicReady()