Пример #1
0
        /// <summary>
        /// Cleanup the MLMusicService and unregister callbacks.
        /// </summary>
        void OnDestroy()
        {
            #if PLATFORM_LUMIN
            if (MLMusicService.IsStarted)
            {
                MLMusicService.StopPlayback();

                MLMusicService.OnPlaybackStateChange -= HandlePlaybackStateChanged;
                MLMusicService.OnShuffleStateChange  -= HandleShuffleStateChanged;
                MLMusicService.OnRepeatStateChange   -= HandleRepeatStateChanged;
                MLMusicService.OnMetadataChange      -= HandleMetadataChanged;
                MLMusicService.OnPositionChange      -= HandlePositionChanged;
                MLMusicService.OnError        -= HandleError;
                MLMusicService.OnStatusChange -= HandleServiceStatusChanged;

                MLMusicService.Stop();
            }
            #endif
        }
        /// <summary>
        /// Cleanup the MLMusicService and unregister from the callbacks
        /// </summary>
        void OnDestroy()
        {
            if (MLMusicService.IsStarted)
            {
                MLMusicService.StopPlayback();

                _playbackBar.OnValueChanged           -= Seek;
                _volumeBar.OnValueChanged             -= SetVolume;
                _playButton.OnToggle                  -= PlayPause;
                _prevButton.OnControllerTriggerDown   -= Previous;
                _nextButton.OnControllerTriggerDown   -= Next;
                _shuffleButton.OnToggle               -= ToggleShuffle;
                _repeatButton.OnControllerTriggerDown -= ChangeRepeatState;
                MLMusicService.OnPlaybackStateChange  -= HandlePlaybackStateChanged;
                MLMusicService.OnShuffleStateChange   -= HandleShuffleStateChanged;
                MLMusicService.OnRepeatStateChange    -= HandleRepeatStateChanged;
                MLMusicService.OnMetadataChange       -= HandleMetadataChanged;
                MLMusicService.OnPositionChange       -= HandlePositionChanged;
                MLMusicService.OnError                -= HandleError;
                MLMusicService.OnStatusChange         -= HandleServiceStatusChanged;

                MLMusicService.Stop();
            }
        }