當前位置: 首頁>>代碼示例>>Java>>正文


Java PlaybackState.Builder方法代碼示例

本文整理匯總了Java中android.media.session.PlaybackState.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java PlaybackState.Builder方法的具體用法?Java PlaybackState.Builder怎麽用?Java PlaybackState.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.session.PlaybackState的用法示例。


在下文中一共展示了PlaybackState.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateMediaSession

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void updateMediaSession(int state) {

        MediaMetadata.Builder mediaBuilder = null;

        Bitmap bitmap = null;
        try {
            URL url = new URL(mRadioIcon);
            bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
        } catch (IOException e) {
            Log.e(TAG, "BitmapFactory.decodeStream", e);
        }

        mediaBuilder = new MediaMetadata.Builder();
        mediaBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, mTitle);
        if (bitmap != null) {
            mediaBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
        }

        mMediaSession.setMetadata(mediaBuilder.build());

        PlaybackState.Builder stateBuilder = new PlaybackState.Builder();
        stateBuilder.setState(state, 0, 1.0f);

        mMediaSession.setPlaybackState(stateBuilder.build());
    }
 
開發者ID:bertrandmartel,項目名稱:webradio-tv-app,代碼行數:26,代碼來源:RadioSingleton.java

示例2: updatePlayState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void updatePlayState() {
    PlaybackState.Builder builder = new PlaybackState.Builder();
    switch (App.MiamPlayer.getState()) {
        case PLAY:
            builder.setState(PlaybackState.STATE_PLAYING, App.MiamPlayer.getSongPosition(),
                    1.0f);
            break;
        case PAUSE:
            builder.setState(PlaybackState.STATE_PAUSED, App.MiamPlayer.getSongPosition(),
                    1.0f);
            break;
        case STOP:
            builder.setState(PlaybackState.STATE_STOPPED, 0, 1.0f);
            break;
        default:
            break;
    }

    mMediaSession.setPlaybackState(builder.build());
}
 
開發者ID:MBach,項目名稱:Miam-Player-remote,代碼行數:21,代碼來源:MiamPlayerMediaSessionV21.java

示例3: updatePlayPauseState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
@Override
protected void updatePlayPauseState() {
    EventBus.getDefault().post(new ToggleSubtitleEvent(mIsSubtitleEnabled));
    EventBus.getDefault().post(new UpdatePlaybackStateEvent(isPlaying()));

    if (mMediaSession != null) {
        PlaybackState.Builder builder = new PlaybackState.Builder();
        builder.setActions(isPlaying()
            ? PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_PAUSE
            : PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_PLAY);
        builder.setState(
            isPlaying() ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_PAUSED,
            getCurrentTime(),
            1.0f);
        mMediaSession.setPlaybackState(builder.build());
    }
}
 
開發者ID:PTCE,項目名稱:popcorn-android,代碼行數:18,代碼來源:PTVVideoPlayerFragment.java

示例4: setCustomAction

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void setCustomAction(PlaybackState.Builder stateBuilder) {
    MediaMetadata currentMusic = getCurrentPlayingMusic();
    if (currentMusic != null) {
        // Set appropriate "Favorite" icon on Custom action:
        String musicId = currentMusic.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
        int favoriteIcon = R.drawable.ic_star_off;
        if (mMusicProvider.isFavorite(musicId)) {
            favoriteIcon = R.drawable.ic_star_on;
        }
        LogHelper.d(TAG, "updatePlaybackState, setting Favorite custom action of music ",
                musicId, " current favorite=", mMusicProvider.isFavorite(musicId));
        Bundle customActionExtras = new Bundle();
        WearHelper.setShowCustomActionOnWear(customActionExtras, true);
        stateBuilder.addCustomAction(new PlaybackState.CustomAction.Builder(
                CUSTOM_ACTION_THUMBS_UP, getString(R.string.favorite), favoriteIcon)
                .setExtras(customActionExtras)
                .build());
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:20,代碼來源:MusicService.java

示例5: updateMediaSession

import android.media.session.PlaybackState; //導入方法依賴的package包/類
public static void updateMediaSession(boolean updateMetadata,
                                      MediaMetadata.Builder mediaBuilder,
                                      final MediaSession mediaSession,
                                      final int playbackState,
                                      final long position,
                                      final float speed) {

    if (mediaSession.isActive()) {

        if (updateMetadata) {
            mediaSession.setMetadata(mediaBuilder.build());
        }
        PlaybackState.Builder stateBuilder = new PlaybackState.Builder();
        stateBuilder.setState(playbackState,
                position,
                speed);
        mediaSession.setPlaybackState(stateBuilder.build());
    }
}
 
開發者ID:bertrandmartel,項目名稱:youtubetv,代碼行數:20,代碼來源:WebviewUtils.java

示例6: updatePlaybackState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void updatePlaybackState(int playbackState) {
    PlaybackState.Builder state = new PlaybackState.Builder();
    long position = player.getCurrentPosition();
    if (ExoPlayer.STATE_PREPARING == playbackState) {
        state.setState(PlaybackState.STATE_CONNECTING, position, 1.0f);
    } else if (ExoPlayer.STATE_BUFFERING == playbackState) {
        state.setState(PlaybackState.STATE_BUFFERING, position, 1.0f);
    } else {
        if (player.getPlayerControl().isPlaying()) {
            state.setState(PlaybackState.STATE_PLAYING, position, 1.0f);
        } else {
            state.setState(PlaybackState.STATE_PAUSED, position, 1.0f);
        }
    }
    mediaSession.setPlaybackState(state.build());
}
 
開發者ID:nextux,項目名稱:sbs-android-tv,代碼行數:17,代碼來源:VideoPlayerActivity.java

示例7: updatePlaybackState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void updatePlaybackState(int position) {
    PlaybackState.Builder stateBuilder = new PlaybackState.Builder()
            .setActions(getAvailableActions());
    int state = PlaybackState.STATE_PLAYING;
    if (mPlaybackState == LeanbackPlaybackState.PAUSED) {
        state = PlaybackState.STATE_PAUSED;
    }
    stateBuilder.setState(state, position, 1.0f);
    mSession.setPlaybackState(stateBuilder.build());
}
 
開發者ID:bassaer,項目名稱:HelloTV,代碼行數:11,代碼來源:PlaybackOverlayActivity.java

示例8: updatePlaybackState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void updatePlaybackState(String error) {
    long position = PlaybackState.PLAYBACK_POSITION_UNKNOWN;
    MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
    if (playingMessageObject != null) {
        position = playingMessageObject.audioProgressSec * 1000;
    }

    PlaybackState.Builder stateBuilder = new PlaybackState.Builder().setActions(getAvailableActions());
    int state;
    if (playingMessageObject == null) {
        state = PlaybackState.STATE_STOPPED;
    } else {
        if (MediaController.getInstance().isDownloadingCurrentMessage()) {
            state = PlaybackState.STATE_BUFFERING;
        } else {
            state = MediaController.getInstance().isAudioPaused() ? PlaybackState.STATE_PAUSED : PlaybackState.STATE_PLAYING;
        }
    }

    if (error != null) {
        stateBuilder.setErrorMessage(error);
        state = PlaybackState.STATE_ERROR;
    }
    stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime());
    if (playingMessageObject != null) {
        stateBuilder.setActiveQueueItemId(MediaController.getInstance().getPlayingMessageObjectNum());
    } else {
        stateBuilder.setActiveQueueItemId(0);
    }

    mediaSession.setPlaybackState(stateBuilder.build());
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:33,代碼來源:MusicBrowserService.java

示例9: setPlaybackState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
@SuppressWarnings("WrongConstant")
private void setPlaybackState(int state) {
	long currentPosition = getCurrentPositionLong();
	PlaybackState.Builder stateBuilder = new PlaybackState.Builder()
			.setActions(getAvailableActions(state))
			.setState(PlaybackState.STATE_PLAYING, currentPosition, 0);

	if (mSession != null) {
		mSession.setPlaybackState(stateBuilder.build());
	}
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:12,代碼來源:OverlayFragment.java

示例10: stopNowPlayingCard

import android.media.session.PlaybackState; //導入方法依賴的package包/類
/**
 * set now playing card to stop
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void stopNowPlayingCard() {
    if(mSession==null)
        return;
    if (DBG) Log.d(TAG, "stopNowPlayingCard");

    PlaybackState.Builder stateBuilder = new PlaybackState.Builder()
            .setActions(getAvailableActions());
    stateBuilder.setState(PlaybackState.STATE_STOPPED, PlaybackState.PLAYBACK_POSITION_UNKNOWN, 1.0f);
    mSession.setPlaybackState(stateBuilder.build());
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:15,代碼來源:PlayerService.java

示例11: newInstance

import android.media.session.PlaybackState; //導入方法依賴的package包/類
public static Object newInstance(int state, long position, long bufferedPosition, float speed, long actions, CharSequence errorMessage, long updateTime, List<Object> customActions, long activeItemId) {
    PlaybackState.Builder stateObj = new PlaybackState.Builder();
    stateObj.setState(state, position, speed, updateTime);
    stateObj.setBufferedPosition(bufferedPosition);
    stateObj.setActions(actions);
    stateObj.setErrorMessage(errorMessage);
    Iterator i$ = customActions.iterator();
    while (i$.hasNext()) {
        stateObj.addCustomAction((android.media.session.PlaybackState.CustomAction) i$.next());
    }
    stateObj.setActiveQueueItemId(activeItemId);
    return stateObj.build();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:PlaybackStateCompatApi21.java

示例12: setMediaSessionPlaybackState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void setMediaSessionPlaybackState(boolean isPlaying) {
    PlaybackState.Builder builder = new PlaybackState.Builder();
    builder.setState(isPlaying ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_STOPPED,
            PlaybackState.PLAYBACK_POSITION_UNKNOWN,
            isPlaying ? MEDIA_SESSION_PLAYING_SPEED : MEDIA_SESSION_STOPPED_SPEED);
    mMediaSession.setPlaybackState(builder.build());
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:8,代碼來源:MainActivity.java

示例13: updatePlaybackState

import android.media.session.PlaybackState; //導入方法依賴的package包/類
private void updatePlaybackState() {
    if (mCallback == null) {
        return;
    }
    PlaybackState.Builder stateBuilder = new PlaybackState.Builder()
            .setActions(getAvailableActions());

    stateBuilder.setState(mState, getCurrentStreamPosition(), 1.0f, SystemClock.elapsedRealtime());
    mCallback.onPlaybackStatusChanged(stateBuilder.build());
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:11,代碼來源:PlaybackManager.java

示例14: onEventMainThread

import android.media.session.PlaybackState; //導入方法依賴的package包/類
@SuppressWarnings("unused")
public void onEventMainThread(StartPlaybackEvent event) {
    togglePlayPause();

    if (mMediaSession != null) {
        PlaybackState.Builder builder = new PlaybackState.Builder();
        builder.setActions(PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE);
        builder.setState(PlaybackState.STATE_PLAYING, getCurrentTime(), 1.0f);
        mMediaSession.setPlaybackState(builder.build());
    }
}
 
開發者ID:PTCE,項目名稱:popcorn-android,代碼行數:12,代碼來源:PTVVideoPlayerFragment.java

示例15: onPlayerStateChanged

import android.media.session.PlaybackState; //導入方法依賴的package包/類
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    PlaybackState.Builder stateBuilder = new PlaybackState.Builder();
    stateBuilder.setState(playWhenReady ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_PAUSED, player.getCurrentPosition(), 1.0f);

    long actions = PlaybackState.ACTION_PLAY;
    if (playWhenReady)
        actions |= PlaybackState.ACTION_PAUSE;

    stateBuilder.setActions(actions);
    session.setPlaybackState(stateBuilder.build());
}
 
開發者ID:irtimmer,項目名稱:itplayer,代碼行數:13,代碼來源:PlayerActivity.java


注:本文中的android.media.session.PlaybackState.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。