当前位置: 首页>>代码示例>>Java>>正文


Java PlaybackStateCompat.STATE_NONE属性代码示例

本文整理汇总了Java中android.support.v4.media.session.PlaybackStateCompat.STATE_NONE属性的典型用法代码示例。如果您正苦于以下问题:Java PlaybackStateCompat.STATE_NONE属性的具体用法?Java PlaybackStateCompat.STATE_NONE怎么用?Java PlaybackStateCompat.STATE_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v4.media.session.PlaybackStateCompat的用法示例。


在下文中一共展示了PlaybackStateCompat.STATE_NONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrawableByState

private Drawable getDrawableByState(Context context, int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_NONE:
            Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(pauseDrawable, colorPlay);
            return pauseDrawable;
        case PlaybackStateCompat.STATE_PLAYING:
            AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(animation, colorPlay);
            animation.start();
            return animation;
        case PlaybackStateCompat.STATE_PAUSED:
            Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(playDrawable, colorPause);
            return playDrawable;
        default:
            Drawable noneDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(noneDrawable, colorPlay);
            return noneDrawable;
    }
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:21,代码来源:AdapterMusic.java

示例2: getView

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    MediaBrowserCompat.MediaItem item = getItem(position);
    int itemState = MediaItemViewHolder.STATE_NONE;
    if (item.isPlayable()) {
        String itemMediaId = item.getDescription().getMediaId();
        int playbackState = PlaybackStateCompat.STATE_NONE;
        if (mCurrentState != null) {
            playbackState = mCurrentState.getState();
        }
        if (mCurrentMetadata != null
                && itemMediaId.equals(mCurrentMetadata.getDescription().getMediaId())) {
            if (playbackState == PlaybackStateCompat.STATE_PLAYING
                    || playbackState == PlaybackStateCompat.STATE_BUFFERING) {
                itemState = MediaItemViewHolder.STATE_PLAYING;
            } else if (playbackState != PlaybackStateCompat.STATE_ERROR) {
                itemState = MediaItemViewHolder.STATE_PAUSED;
            }
        }
    }
    return MediaItemViewHolder.setupView(
            (Activity) getContext(), convertView, parent, item.getDescription(), itemState);
}
 
开发者ID:googlecodelabs,项目名称:musicplayer-devices,代码行数:23,代码来源:MusicPlayerActivity.java

示例3: getView

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    MediaBrowserCompat.MediaItem item = getItem(position);
    int itemState = MediaItemViewHolder.STATE_NONE;
    if (item.isPlayable()) {
        String itemMediaId = item.getDescription().getMediaId();
        int playbackState = PlaybackStateCompat.STATE_NONE;
        if (mCurrentState != null) {
            playbackState = mCurrentState.getState();
        }
        if (mCurrentMetadata != null
                && itemMediaId.equals(mCurrentMetadata.getDescription().getMediaId())) {
            if (playbackState == PlaybackState.STATE_PLAYING
                    || playbackState == PlaybackState.STATE_BUFFERING) {
                itemState = MediaItemViewHolder.STATE_PLAYING;
            } else if (playbackState != PlaybackState.STATE_ERROR) {
                itemState = MediaItemViewHolder.STATE_PAUSED;
            }
        }
    }
    return MediaItemViewHolder.setupView(
            (Activity) getContext(), convertView, parent, item.getDescription(), itemState);
}
 
开发者ID:googlecodelabs,项目名称:musicplayer-devices,代码行数:23,代码来源:MusicPlayerActivity.java

示例4: playPause

@OnClick(R.id.play_pause)
public void playPause(){
    lastState=null;
    MediaControllerCompat controllerCompat=MediaControllerCompat.getMediaController(getActivity());
    PlaybackStateCompat stateCompat=controllerCompat.getPlaybackState();
    if(stateCompat!=null){
        MediaControllerCompat.TransportControls controls=
                controllerCompat.getTransportControls();
        switch (stateCompat.getState()){
            case PlaybackStateCompat.STATE_PLAYING:
            case PlaybackStateCompat.STATE_BUFFERING:
                controls.pause();
                break;
            case PlaybackStateCompat.STATE_NONE:
            case PlaybackStateCompat.STATE_PAUSED:
            case PlaybackStateCompat.STATE_STOPPED:
                controls.play();
                break;
            default:
                Log.d(TAG, "State "+stateCompat.getState());
        }
    }
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:23,代码来源:TrackFragment.java

示例5: playbackStateToName

private String playbackStateToName(final int playbackState) {
    switch (playbackState) {
        case PlaybackStateCompat.STATE_NONE:
            return "STATE_NONE";
        case PlaybackStateCompat.STATE_STOPPED:
            return "STATE_STOPPED";
        case PlaybackStateCompat.STATE_PAUSED:
            return "STATE_PAUSED";
        case PlaybackStateCompat.STATE_PLAYING:
            return "STATE_PLAYING";
        case PlaybackStateCompat.STATE_FAST_FORWARDING:
            return "STATE_FAST_FORWARDING";
        case PlaybackStateCompat.STATE_REWINDING:
            return "STATE_REWINDING";
        case PlaybackStateCompat.STATE_BUFFERING:
            return "STATE_BUFFERING";
        case PlaybackStateCompat.STATE_ERROR:
            return "STATE_ERROR";
        case PlaybackStateCompat.STATE_CONNECTING:
            return "STATE_CONNECTING";
        case PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS:
            return "STATE_SKIPPING_TO_PREVIOUS";
        case PlaybackStateCompat.STATE_SKIPPING_TO_NEXT:
            return "STATE_SKIPPING_TO_NEXT";
        case PlaybackStateCompat.STATE_SKIPPING_TO_QUEUE_ITEM:
            return "STATE_SKIPPING_TO_QUEUE_ITEM";
        default:
            return "!Unknown State!";
    }
}
 
开发者ID:googlesamples,项目名称:android-media-controller,代码行数:30,代码来源:MediaAppControllerActivity.java

示例6: onClick

@Override
public void onClick(View v) {
    final int state =
            mCurrentState == null
                    ? PlaybackStateCompat.STATE_NONE
                    : mCurrentState.getState();
    if (state == PlaybackStateCompat.STATE_PAUSED
            || state == PlaybackStateCompat.STATE_STOPPED
            || state == PlaybackStateCompat.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata =
                    MusicLibrary.getMetadata(
                            MusicPlayerActivity.this,
                            MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }

        // TODO: [5] Remove the following line for playback in a Service
        mPlaybackManager.play(mCurrentMetadata);

        // TODO: [5] Uncomment the following block for playback in a Service
        /*
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .playFromMediaId(
                        mCurrentMetadata.getDescription().getMediaId(), null);
        */
    } else {
        // TODO: [6] Remove the following line for playback in a Service
        mPlaybackManager.pause();

        // TODO: [6] Uncomment the following block for playback in a Service
        /*
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .pause();
        */
    }
}
 
开发者ID:googlecodelabs,项目名称:musicplayer-devices,代码行数:40,代码来源:MusicPlayerActivity.java

示例7: onClick

@Override
public void onClick(View v) {
    final int state =
            mCurrentState == null
                    ? PlaybackStateCompat.STATE_NONE
                    : mCurrentState.getState();
    if (state == PlaybackState.STATE_PAUSED
            || state == PlaybackState.STATE_STOPPED
            || state == PlaybackState.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata =
                    MusicLibrary.getMetadata(
                            MusicPlayerActivity.this,
                            MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .playFromMediaId(
                        mCurrentMetadata.getDescription().getMediaId(), null);
    } else {
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .pause();
    }
}
 
开发者ID:googlecodelabs,项目名称:musicplayer-devices,代码行数:27,代码来源:MusicPlayerActivity.java

示例8: onPlaybackStateChanged

@Override
public void onPlaybackStateChanged(PlaybackStateCompat state) {
    mPlaybackState = state;
    Log.i(TAG, "onPlaybackStateChanged: received new play state : " + state);
    if (state.getState() == PlaybackStateCompat.STATE_STOPPED ||
            state.getState() == PlaybackStateCompat.STATE_NONE) {
        stopNotification();
    } else {
        Notification notification = buildNotification();
        if (notification != null) {
            mNotificationManager.notify(NOTIFICATION_ID, notification);
        }
    }

}
 
开发者ID:Jaysaw,项目名称:NovaMusicPlayer,代码行数:15,代码来源:NovaNotificationManager.java

示例9: Playback

public Playback(Context context) {
    this.mContext = context;
    this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    // Create the Wifi lock (this does not acquire the lock, this just creates it)
    this.mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE))
            .createWifiLock(WifiManager.WIFI_MODE_FULL, "playback_lock");
    this.mState = PlaybackStateCompat.STATE_NONE;
}
 
开发者ID:AllThatSeries,项目名称:react-native-streaming-audio-player,代码行数:8,代码来源:Playback.java

示例10: onPlaybackStateChanged

@Override
public void onPlaybackStateChanged(@NonNull PlaybackStateCompat state) {
    mPlaybackState = state;
    if (state.getState() == PlaybackStateCompat.STATE_STOPPED ||
            state.getState() == PlaybackStateCompat.STATE_NONE) {
        stopNotification();
    } else {
        Notification notification = createNotification();
        if (notification != null) {
            mNotificationManager.notify(NOTIFICATION_ID, notification);
        }
    }
}
 
开发者ID:AllThatSeries,项目名称:react-native-streaming-audio-player,代码行数:13,代码来源:MediaNotificationManager.java

示例11: updatePlaybackState

public void updatePlaybackState(PlaybackStateCompat playbackState){
    this.playbackState=playbackState;
    if(playbackState.getState()==PlaybackStateCompat.STATE_STOPPED||
            playbackState.getState()==PlaybackStateCompat.STATE_NONE){
        stopNotification();
    }else{
        updateNotification();
    }
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:9,代码来源:TrackNotification.java

示例12: updatePlaybackState

@Override
public void updatePlaybackState(int state) {
    Logger.e("updatePlaybackState: ", "" + state);
    switch (state) {
        case PlaybackStateCompat.STATE_PLAYING:
            pgPlayPauseLayout.setVisibility(View.INVISIBLE);
            btn_play.Play();
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_PLAYING);
                notifyAdapter(currentSong);
            }
            break;
        case PlaybackStateCompat.STATE_PAUSED:
            pgPlayPauseLayout.setVisibility(View.INVISIBLE);
            btn_play.Pause();
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_PAUSED);
                notifyAdapter(currentSong);
            }
            break;
        case PlaybackStateCompat.STATE_NONE:
            currentSong.setPlayState(PlaybackStateCompat.STATE_NONE);
            notifyAdapter(currentSong);
            break;
        case PlaybackStateCompat.STATE_STOPPED:
            pgPlayPauseLayout.setVisibility(View.INVISIBLE);
            btn_play.Pause();
            audioPg.setValue(0);
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_NONE);
                notifyAdapter(currentSong);
            }
            break;
        case PlaybackStateCompat.STATE_BUFFERING:
            pgPlayPauseLayout.setVisibility(View.VISIBLE);
            if (currentSong != null) {
                currentSong.setPlayState(PlaybackStateCompat.STATE_NONE);
                notifyAdapter(currentSong);
            }
            break;
    }
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:42,代码来源:MusicActivity.java

示例13: AudioPlaybackListener

public AudioPlaybackListener(Context context) {
    this.mContext = context;
    this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    this.mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "dmAudioStreaming_Lock");
    this.mState = PlaybackStateCompat.STATE_NONE;
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:6,代码来源:AudioPlaybackListener.java

示例14: update

public void update(
        MediaMetadataCompat metadata,
        PlaybackStateCompat state,
        MediaSessionCompat.Token token) {
    if (state == null
            || state.getState() == PlaybackStateCompat.STATE_STOPPED
            || state.getState() == PlaybackStateCompat.STATE_NONE) {
        mService.stopForeground(true);
        try {
            mService.unregisterReceiver(this);
        } catch (IllegalArgumentException ex) {
            // ignore receiver not registered
        }
        mService.stopSelf();
        return;
    }
    if (metadata == null) {
        return;
    }
    boolean isPlaying = state.getState() == PlaybackStateCompat.STATE_PLAYING;
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService);
    MediaDescriptionCompat description = metadata.getDescription();

    notificationBuilder
            .setStyle(
                    new NotificationCompat.MediaStyle()
                            .setMediaSession(token)
                            .setShowActionsInCompactView(0, 1, 2))
            .setColor(
                    mService.getApplication().getResources().getColor(R.color.notification_bg))
            .setSmallIcon(R.drawable.ic_notification)
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setContentIntent(createContentIntent())
            .setContentTitle(description.getTitle())
            .setContentText(description.getSubtitle())
            .setLargeIcon(MusicLibrary.getAlbumBitmap(mService, description.getMediaId()))
            .setOngoing(isPlaying)
            .setWhen(isPlaying ? System.currentTimeMillis() - state.getPosition() : 0)
            .setShowWhen(isPlaying)
            .setUsesChronometer(isPlaying);

    // If skip to next action is enabled
    if ((state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) {
        notificationBuilder.addAction(mPrevAction);
    }

    notificationBuilder.addAction(isPlaying ? mPauseAction : mPlayAction);

    // If skip to prev action is enabled
    if ((state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) {
        notificationBuilder.addAction(mNextAction);
    }

    Notification notification = notificationBuilder.build();

    if (isPlaying && !mStarted) {
        mService.startService(new Intent(mService.getApplicationContext(), MusicService.class));
        mService.startForeground(NOTIFICATION_ID, notification);
        mStarted = true;
    } else {
        if (!isPlaying) {
            mService.stopForeground(false);
            mStarted = false;
        }
        mNotificationManager.notify(NOTIFICATION_ID, notification);
    }
}
 
开发者ID:googlecodelabs,项目名称:musicplayer-devices,代码行数:67,代码来源:MediaNotificationManager.java

示例15: updatePlaybackState

public void updatePlaybackState(PlaybackStateCompat stateCompat){
    if(stateCompat==null) return;
    lastState=stateCompat;
    updateRepeatMode(isActionApplied(stateCompat.getActions(),
            PlaybackStateCompat.ACTION_SET_REPEAT_MODE));
    updateShuffleMode(isActionApplied(stateCompat.getActions(),
            PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE_ENABLED));
    //check the state
    switch (stateCompat.getState()){
        case PlaybackStateCompat.STATE_PLAYING:
            playPause.setVisibility(VISIBLE);
            if(playPause.isPlay()){
                playPause.change(false,true);
            }
            startSeekBarUpdate();
            break;
        case PlaybackStateCompat.STATE_PAUSED:
            // mControllers.setVisibility(VISIBLE);
            // mLoading.setVisibility(INVISIBLE);
            playPause.setVisibility(VISIBLE);
            if(!playPause.isPlay()){
                playPause.change(true,true);
            }
            stopSeekBarUpdate();
            break;
        case PlaybackStateCompat.STATE_NONE:
        case PlaybackStateCompat.STATE_STOPPED:
            playPause.setVisibility(VISIBLE);
            if(playPause.isPlay()){
                playPause.change(false,true);
            }
            stopSeekBarUpdate();
            break;
        case PlaybackStateCompat.STATE_BUFFERING:
            playPause.setVisibility(INVISIBLE);
            stopSeekBarUpdate();
            break;
        default:
            Log.d(TAG, "Unhandled state "+stateCompat.getState());
    }
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:41,代码来源:TrackFragment.java


注:本文中的android.support.v4.media.session.PlaybackStateCompat.STATE_NONE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。