Search in sources :

Example 1 with MediaPlayerState

use of com.waz.zclient.controllers.mediaplayer.MediaPlayerState in project wire-android by wireapp.

the class SpotifyMediaPlayer method onLoggedIn.

@Override
public void onLoggedIn() {
    if (mediaPlayerState == MediaPlayerState.Paused) {
        mediaPlayer.getPlayerState(new PlayerStateCallback() {

            @Override
            public void onPlayerState(PlayerState playerState) {
                if (dataSource.toString().equals(playerState.trackUri)) {
                    mediaPlayer.resume();
                } else {
                    reset();
                    onLoggedIn();
                }
            }
        });
    } else {
        if (listener != null && !mediaPlayerState.isStartAllowed()) {
            setState(MediaPlayerState.Prepared);
            listener.onPrepared();
        } else {
            mediaPlayer.play(PlayConfig.createFor(dataSource.toString()).withInitialPosition(currentPosition));
        }
    }
}
Also used : MediaPlayerState(com.waz.zclient.controllers.mediaplayer.MediaPlayerState) PlayerState(com.spotify.sdk.android.player.PlayerState) PlayerStateCallback(com.spotify.sdk.android.player.PlayerStateCallback)

Example 2 with MediaPlayerState

use of com.waz.zclient.controllers.mediaplayer.MediaPlayerState in project wire-android by wireapp.

the class RightIndicatorView method updateMediaPlayerIndicator.

private boolean updateMediaPlayerIndicator() {
    if (streamMediaPlayerController == null) {
        mediaControlView.setVisibility(GONE);
        return false;
    }
    MediaPlayerState mediaPlayerState = streamMediaPlayerController.getMediaPlayerState(conversation.getId());
    if (!streamMediaPlayerController.isSelectedConversation(conversation.getId()) || mediaPlayerState == MediaPlayerState.PlaybackCompleted || mediaPlayerState == MediaPlayerState.Stopped) {
        mediaControlView.setVisibility(GONE);
        return false;
    }
    if (mediaPlayerState.isPauseControl()) {
        mediaControlView.setText(R.string.glyph__pause);
        mediaControlView.setVisibility(VISIBLE);
        return true;
    } else if (mediaPlayerState.isPlayControl()) {
        mediaControlView.setText(R.string.glyph__play);
        mediaControlView.setVisibility(VISIBLE);
        return true;
    } else {
        mediaControlView.setVisibility(GONE);
        return false;
    }
}
Also used : MediaPlayerState(com.waz.zclient.controllers.mediaplayer.MediaPlayerState)

Example 3 with MediaPlayerState

use of com.waz.zclient.controllers.mediaplayer.MediaPlayerState in project wire-android by wireapp.

the class MediaPlayerView method setAllowControl.

public void setAllowControl(boolean allowControl) {
    this.allowControl = allowControl;
    final MediaPlayerState state = lastMediaState;
    this.lastMediaState = null;
    updateControl(state);
}
Also used : MediaPlayerState(com.waz.zclient.controllers.mediaplayer.MediaPlayerState)

Example 4 with MediaPlayerState

use of com.waz.zclient.controllers.mediaplayer.MediaPlayerState in project wire-android by wireapp.

the class StreamMediaPlayerBarFragment method updateMediaPlayerIndicator.

private void updateMediaPlayerIndicator() {
    if (streamMediaController == null) {
        return;
    }
    Message trackMetaData = streamMediaController.getMessage();
    MediaPlayerState mediaPlayerState = streamMediaController.getMediaPlayerState(trackMetaData);
    if (mediaPlayerState == MediaPlayerState.PlaybackCompleted) {
        return;
    }
    if (mediaPlayerState.isPauseControl()) {
        toolbar.setNavigationIcon(ThemeUtils.isDarkTheme(getContext()) ? R.drawable.ic_action_pause_light : R.drawable.ic_action_pause_dark);
    } else if (mediaPlayerState.isPlayControl()) {
        toolbar.setNavigationIcon(ThemeUtils.isDarkTheme(getContext()) ? R.drawable.ic_action_play_light : R.drawable.ic_action_play_dark);
    }
}
Also used : Message(com.waz.api.Message) MediaPlayerState(com.waz.zclient.controllers.mediaplayer.MediaPlayerState)

Aggregations

MediaPlayerState (com.waz.zclient.controllers.mediaplayer.MediaPlayerState)4 PlayerState (com.spotify.sdk.android.player.PlayerState)1 PlayerStateCallback (com.spotify.sdk.android.player.PlayerStateCallback)1 Message (com.waz.api.Message)1