Java Code Examples for android.media.RemoteControlClient#PLAYSTATE_PAUSED

The following examples show how to use android.media.RemoteControlClient#PLAYSTATE_PAUSED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MusicTile.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private void playbackStateUpdate(int state) {
    boolean active;
    switch (state) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
            active = true;
            break;
        case RemoteControlClient.PLAYSTATE_ERROR:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        default:
            active = false;
            break;
    }
    if (active != mActive) {
        mActive = active;
        refreshState();
        if (DEBUG) log(getKey() + ": playbackStateUpdate("+state+")");
    }
}
 
Example 2
Source File: MediaProviderDelegate.java    From Noyze with Apache License 2.0 6 votes vote down vote up
static int getStateFromPlayState(PlayState playState) {
    switch (playState) {
        case BUFFERING:
            return RemoteControlClient.PLAYSTATE_BUFFERING;
        case ERROR:
            return RemoteControlClient.PLAYSTATE_ERROR;
        case FAST_FORWARDING:
            return RemoteControlClient.PLAYSTATE_FAST_FORWARDING;
        case PAUSED:
            return RemoteControlClient.PLAYSTATE_PAUSED;
        case PLAYING:
            return RemoteControlClient.PLAYSTATE_PLAYING;
        case REWINDING:
            return RemoteControlClient.PLAYSTATE_REWINDING;
        case SKIPPING_BACKWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS;
        case SKIPPING_FORWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS;
        case STOPPED:
            return RemoteControlClient.PLAYSTATE_STOPPED;
        default:
            return RemoteControlClient.PLAYSTATE_ERROR;
    }
}
 
Example 3
Source File: PlaybackInfo.java    From Noyze with Apache License 2.0 6 votes vote down vote up
public boolean wasPlayingRecently() {
    switch (mState) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
        case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
        case RemoteControlClient.PLAYSTATE_REWINDING:
        case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
        case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
        case RemoteControlClient.PLAYSTATE_BUFFERING:
            // actively playing or about to play
            return true;
        case RemoteControlClient.PLAYSTATE_STOPPED:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        case RemoteControlClient.PLAYSTATE_ERROR:
            return ((SystemClock.elapsedRealtime() - mStateChangeTimeMs) < DISPLAY_TIMEOUT_MS);
        default:
            LOGE("PlaybackInfo", "Unknown playback state " + mState + " in wasPlayingRecently()");
            return false;
    }
}
 
Example 4
Source File: MediaProviderDelegate.java    From Noyze with Apache License 2.0 6 votes vote down vote up
static int getStateFromPlayState(PlayState playState) {
    switch (playState) {
        case BUFFERING:
            return RemoteControlClient.PLAYSTATE_BUFFERING;
        case ERROR:
            return RemoteControlClient.PLAYSTATE_ERROR;
        case FAST_FORWARDING:
            return RemoteControlClient.PLAYSTATE_FAST_FORWARDING;
        case PAUSED:
            return RemoteControlClient.PLAYSTATE_PAUSED;
        case PLAYING:
            return RemoteControlClient.PLAYSTATE_PLAYING;
        case REWINDING:
            return RemoteControlClient.PLAYSTATE_REWINDING;
        case SKIPPING_BACKWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS;
        case SKIPPING_FORWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS;
        case STOPPED:
            return RemoteControlClient.PLAYSTATE_STOPPED;
        default:
            return RemoteControlClient.PLAYSTATE_ERROR;
    }
}
 
Example 5
Source File: PlaybackInfo.java    From Noyze with Apache License 2.0 6 votes vote down vote up
public boolean wasPlayingRecently() {
    switch (mState) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
        case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
        case RemoteControlClient.PLAYSTATE_REWINDING:
        case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
        case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
        case RemoteControlClient.PLAYSTATE_BUFFERING:
            // actively playing or about to play
            return true;
        case RemoteControlClient.PLAYSTATE_STOPPED:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        case RemoteControlClient.PLAYSTATE_ERROR:
            return ((SystemClock.elapsedRealtime() - mStateChangeTimeMs) < DISPLAY_TIMEOUT_MS);
        default:
            LOGE("PlaybackInfo", "Unknown playback state " + mState + " in wasPlayingRecently()");
            return false;
    }
}
 
Example 6
Source File: RemoteControlClientJB.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setPlaybackState(final int state, int index, int queueSize) {
	if(mRemoteControl == null) {
		return;
	}

	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	mRemoteControl.setPlaybackState(state, position, 1.0f);
}
 
Example 7
Source File: TransportMediatorJellybeanMR2.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void pausePlaying() {
    if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
    }
    dropAudioFocus();
}
 
Example 8
Source File: TransportMediatorJellybeanMR2.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
public void pausePlaying() {
    if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
    }
    dropAudioFocus();
}
 
Example 9
Source File: TransportMediatorJellybeanMR2.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
public void pausePlaying() {
    if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
    }
    dropAudioFocus();
}
 
Example 10
Source File: TransportMediatorJellybeanMR2.java    From guideshow with MIT License 5 votes vote down vote up
public void pausePlaying() {
    if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
    }
    dropAudioFocus();
}
 
Example 11
Source File: RemoteControlClientLP.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setPlaybackState(int state, int index, int queueSize) {
	PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder();

	int newState = PlaybackStateCompat.STATE_NONE;
	switch(state) {
		case RemoteControlClient.PLAYSTATE_PLAYING:
			newState = PlaybackStateCompat.STATE_PLAYING;
			break;
		case RemoteControlClient.PLAYSTATE_STOPPED:
			newState = PlaybackStateCompat.STATE_STOPPED;
			break;
		case RemoteControlClient.PLAYSTATE_PAUSED:
			newState = PlaybackStateCompat.STATE_PAUSED;
			break;
		case RemoteControlClient.PLAYSTATE_BUFFERING:
			newState = PlaybackStateCompat.STATE_BUFFERING;
			break;
	}

	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	builder.setState(newState, position, 1.0f);
	DownloadFile downloadFile = downloadService.getCurrentPlaying();
	Entry entry = null;
	boolean isSong = true;
	if(downloadFile != null) {
		entry = downloadFile.getSong();
		isSong = entry.isSong();
	}

	builder.setActions(getPlaybackActions(isSong, index, queueSize));

	if(entry != null) {
		addCustomActions(entry, builder);
		builder.setActiveQueueItemId(entry.getId().hashCode());
	}

	PlaybackStateCompat playbackState = builder.build();
	mediaSession.setPlaybackState(playbackState);
	previousState = state;
}