private void MusicController_MediaPlaybackChanged(object sender, MediaPlaybackStateChangedEventArgs e)
        {
            switch (e.PlaybackState)
            {
            case PlaybackStateCode.Paused:
                btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_play_arrow_white_24dp, 0, 0);
                playbackState = PlaybackStateCode.Paused;
                MoveSeekbar(false);

                break;

            case PlaybackStateCode.Playing:
                btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_pause_white_24dp, 0, 0);
                playbackState = PlaybackStateCode.Playing;
                MoveSeekbar(true);

                break;

            case PlaybackStateCode.Stopped:
                btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_play_arrow_white_24dp, 0, 0);
                playbackState = PlaybackStateCode.Stopped;
                MoveSeekbar(false);
                break;

            default:
                break;
            }
            skbSeekSongTime.SetProgress((int)e.CurrentTime, true);
        }
Esempio n. 2
0
        protected virtual void OnMediaPlaybackChanged(MediaPlaybackStateChangedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(m =>
            {
                switch (e.PlaybackState)
                {
                case PlaybackStateCode.Playing:
                    MusicPlaying?.Invoke(this, EventArgs.Empty);
                    break;

                case PlaybackStateCode.Paused:
                    MusicPaused?.Invoke(this, EventArgs.Empty);
                    break;
                }
                MediaPlaybackChanged?.Invoke(this, e);
            });
        }
Esempio n. 3
0
        private void MusicController_MediaPlaybackChanged(object sender, MediaPlaybackStateChangedEventArgs e)
        {
            Activity?.RunOnUiThread(() =>
            {
                switch (e.PlaybackState)
                {
                case PlaybackStateCode.Paused:
                    SetMediaControlButtonsAvailability(true);
                    btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_play_arrow_white_24dp, 0, 0);
                    playbackState = PlaybackStateCode.Paused;
                    //Start timeout to hide the MusicFragment (but only if the music method chosen is 'Pick a MediaSession' (0)
                    //Otherwise, the Music Widget can only disappear when the notification is removed. (which is the correct behavior)
                    if (configurationManager.RetrieveAValue(ConfigurationParameters.MusicWidgetMethod, "1") == "0")
                    {
                        StartTimeout(true);
                    }
                    MoveSeekbar(false);

                    break;

                case PlaybackStateCode.Playing:
                    SetMediaControlButtonsAvailability(true);
                    btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_pause_white_24dp, 0, 0);
                    playbackState = PlaybackStateCode.Playing;
                    StartTimeout(false);
                    MoveSeekbar(true);

                    break;

                case PlaybackStateCode.Stopped:
                    //HideMusicWidget();
                    btnPlayPause.SetCompoundDrawablesRelativeWithIntrinsicBounds(0, Resource.Drawable.ic_replay_white_24dp, 0, 0);
                    playbackState = PlaybackStateCode.Stopped;
                    MoveSeekbar(false);
                    break;

                case PlaybackStateCode.Buffering:
                    SetMediaControlButtonsAvailability(false);
                    break;

                default:
                    break;
                }
                skbSeekSongTime.SetProgress((int)e.CurrentTime / 1000, true);
            });
        }
 protected virtual void OnMediaPlaybackChanged(MediaPlaybackStateChangedEventArgs e)
 {
     MediaPlaybackChanged?.Invoke(this, e);
 }