Exemplo n.º 1
0
        internal override void ProcessMusicError(SoundMusicEventNotification eventNotification)
        {
            if (eventNotification.Event != SoundMusicEvent.ErrorOccurred) // no errors
            {
                return;
            }

            var soundMusicName = "Unknown";

            if (CurrentMusic != null)
            {
                CurrentMusic.SetStateToStopped();
                soundMusicName = CurrentMusic.Name;
            }

            Logger.Error("Error while playing the sound music '{0}'. Details follows:");

            var errorEvent = (MediaPlayer.ErrorEventArgs)eventNotification.EventData;

            if (errorEvent.What == MediaError.Unknown && errorEvent.Extra == 0xfffffc0e) // MEDIA_ERROR_UNSUPPORTED (Hardware dependent?)
            {
                Logger.Error("The data format of the music file is not supported.");
            }
            else if ((uint)errorEvent.What == 0xffffffed) // underlying audio track returned -12 (no memory) -> try to recreate the player once more
            {
                Logger.Error("The OS did not have enough memory to create the audio track.", soundMusicName);
            }
            else
            {
                Logger.Error(" [Details: ErrorCode={1}, Extra={2}]", soundMusicName, errorEvent.What, errorEvent.Extra);
            }

            // reset the music player to a valid state for future plays
            ResetMusicPlayer();
        }
Exemplo n.º 2
0
        internal override void StartMusic()
        {
            if (audioPlayer == null)
            {
                return;
            }

            if (!audioPlayer.Play())
            {
                // this happens sometimes when we put the application on background when starting to play.
                var currentMusicName = CurrentMusic.Name;
                CurrentMusic.SetStateToStopped();
                ResetMusicPlayer();

                Logger.Warning("The music '{0}' failed to start playing.", currentMusicName);
            }
        }