当前位置: 首页>>代码示例>>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;未经允许,请勿转载。