private void UpdatePlaybackState(String error) { var position = PlaybackState.PlaybackPositionUnknown; if (_musicPlayer != null) { position = _musicPlayer.CurrentStreamPosition; } var stateBuilder = new PlaybackState.Builder() .SetActions(GetAvailableActions()); SetCustomAction(stateBuilder); if (error != null) { stateBuilder.SetErrorMessage(error); stateBuilder.SetState(PlaybackStateCode.Error, position, 1.0f, SystemClock.ElapsedRealtime()); } else { stateBuilder.SetState(_musicPlayer.MusicPlayerState, position, 1.0f, SystemClock.ElapsedRealtime()); } if (this.isIndexPlayable(_currentIndexQueue, _playingQueue)) { var item = _playingQueue[_currentIndexQueue]; stateBuilder.SetActiveQueueItemId(item.QueueId); } _session.SetPlaybackState(stateBuilder.Build()); }
void UpdatePlaybackState(String error) { LogHelper.Debug(Tag, "updatePlaybackState, playback state=" + playback.State); var position = PlaybackState.PlaybackPositionUnknown; if (playback != null && playback.IsConnected) { position = playback.CurrentStreamPosition; } var stateBuilder = new PlaybackState.Builder() .SetActions(GetAvailableActions()); SetCustomAction(stateBuilder); var state = playback.State; // If there is an error message, send it to the playback state: if (error != null) { // Error states are really only supposed to be used for errors that cause playback to // stop unexpectedly and persist until the user takes action to fix it. stateBuilder.SetErrorMessage(error); state = PlaybackStateCode.Error; } stateBuilder.SetState(state, position, 1.0f, SystemClock.ElapsedRealtime()); // Set the activeQueueItemId if the current index is valid. if (QueueHelper.isIndexPlayable(currentIndexOnQueue, playingQueue)) { var item = playingQueue [currentIndexOnQueue]; stateBuilder.SetActiveQueueItemId(item.QueueId); } session.SetPlaybackState(stateBuilder.Build()); if (state == PlaybackStateCode.Playing || state == PlaybackStateCode.Paused) { mediaNotificationManager.StartNotification(); } }
void UpdatePlaybackState (String error) { LogHelper.Debug (Tag, "updatePlaybackState, playback state=" + playback.State); var position = PlaybackState.PlaybackPositionUnknown; if (playback != null && playback.IsConnected) { position = playback.CurrentStreamPosition; } var stateBuilder = new PlaybackState.Builder () .SetActions (GetAvailableActions ()); SetCustomAction (stateBuilder); PlaybackStateCode state = playback.State; // If there is an error message, send it to the playback state: if (error != null) { // Error states are really only supposed to be used for errors that cause playback to // stop unexpectedly and persist until the user takes action to fix it. stateBuilder.SetErrorMessage (error); state = PlaybackStateCode.Error; } stateBuilder.SetState (state, position, 1.0f, SystemClock.ElapsedRealtime ()); // Set the activeQueueItemId if the current index is valid. if (QueueHelper.isIndexPlayable (currentIndexOnQueue, playingQueue)) { var item = playingQueue [currentIndexOnQueue]; stateBuilder.SetActiveQueueItemId (item.QueueId); } session.SetPlaybackState (stateBuilder.Build ()); if (state == PlaybackStateCode.Playing || state == PlaybackStateCode.Paused) { mediaNotificationManager.StartNotification (); } }