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


Java RemoteControlClient.PLAYSTATE_PLAYING属性代码示例

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


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

示例1: playbackStateUpdate

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+")");
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:MusicTile.java

示例2: getStateFromPlayState

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;
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:24,代码来源:MediaProviderDelegate.java

示例3: wasPlayingRecently

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;
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:19,代码来源:PlaybackInfo.java

示例4: updateRemoteControlClient

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClient(final String what) {
    //Legacy for ICS
    if (mRemoteControlClient != null) {
        int playState = mIsSupposedToBePlaying
                ? RemoteControlClient.PLAYSTATE_PLAYING
                : RemoteControlClient.PLAYSTATE_PAUSED;
        if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) {
            Bitmap albumArt = null;
            if (mShowAlbumArtOnLockscreen) {
                albumArt = ImageLoader.getInstance().loadImageSync(TimberUtils.getAlbumArtUri(getAlbumId()).toString());
                if (albumArt != null) {

                    Bitmap.Config config = albumArt.getConfig();
                    if (config == null) {
                        config = Bitmap.Config.ARGB_8888;
                    }
                    albumArt = albumArt.copy(config, false);
                }
            }

            RemoteControlClient.MetadataEditor editor = mRemoteControlClient.editMetadata(true);
            editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
            editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
            editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
            editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
            editor.putBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, albumArt);
            editor.apply();

        }
        mRemoteControlClient.setPlaybackState(playState);
    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:34,代码来源:MusicService.java

示例5: isRemoteControlPlaying

public static boolean isRemoteControlPlaying(final int state) {
    switch (state) {
        case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
        case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
        case RemoteControlClient.PLAYSTATE_BUFFERING:
        case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
        case RemoteControlClient.PLAYSTATE_PLAYING:
        case RemoteControlClient.PLAYSTATE_REWINDING:
            return true;
    }

    return false;
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:13,代码来源:Constants.java

示例6: gainFocus

void gainFocus() {
    if (!mFocused) {
        mFocused = true;
        mAudioManager.registerMediaButtonEventReceiver(mPendingIntent);
        mAudioManager.registerRemoteControlClient(mRemoteControl);
        if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
            takeAudioFocus();
        }
    }
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:10,代码来源:TransportMediatorJellybeanMR2.java

示例7: startPlaying

public void startPlaying() {
    if (mPlayState != RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PLAYING;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
    }
    if (mFocused) {
        takeAudioFocus();
    }
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:9,代码来源:TransportMediatorJellybeanMR2.java

示例8: pausePlaying

public void pausePlaying() {
    if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
    }
    dropAudioFocus();
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:7,代码来源:TransportMediatorJellybeanMR2.java

示例9: setPlaybackState

@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);
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:12,代码来源:RemoteControlClientJB.java

示例10: setPlaybackState

@Override
public void setPlaybackState(final int state) {
	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	mRemoteControl.setPlaybackState(state, position, 1.0f);
}
 
开发者ID:MadMarty,项目名称:madsonic-5.5,代码行数:8,代码来源:RemoteControlClientJB.java

示例11: updateMeta

@Override
void updateMeta(String what) {
    int playState = mService.isPlaying()
            ? RemoteControlClient.PLAYSTATE_PLAYING
            : RemoteControlClient.PLAYSTATE_PAUSED;

    if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
        setPlaybackState(playState);
    } else if (what.equals(META_CHANGED)) {
        Bitmap albumArt;
        if (VersionUtils.hasKitkat()) {
            //Kitkat has fullscreen artwork
            albumArt = mService.getAlbumArt();
        } else {
            albumArt = mService.getAlbumArtThumbnail();
        }
        if (albumArt != null) {
            // RemoteControlClient wants to recycle the bitmaps thrown at it, so we need
            // to make sure not to hand out our cache copy
            Bitmap.Config config = albumArt.getConfig();
            if (config == null) {
                config = Bitmap.Config.ARGB_8888;
            }
            albumArt = albumArt.copy(config, false);
        }

        mRemoteControlClient
                .editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, mService.getArtistName())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST,
                        !TextUtils.isEmpty(mService.getAlbumArtistName()) ? mService.getAlbumArtistName() : mService.getArtistName())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mService.getAlbumName())
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mService.getTrackName())
                .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, mService.duration())
                .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, albumArt)
                .apply();

        setPlaybackState(playState);
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:40,代码来源:MediaSessionHelper.java

示例12: setPlaybackState

@Override
public void setPlaybackState(int state, int index, int queueSize) {
	PlaybackState.Builder builder = new PlaybackState.Builder();

	int newState = PlaybackState.STATE_NONE;
	switch(state) {
		case RemoteControlClient.PLAYSTATE_PLAYING:
			newState = PlaybackState.STATE_PLAYING;
			break;
		case RemoteControlClient.PLAYSTATE_STOPPED:
			newState = PlaybackState.STATE_STOPPED;
			break;
		case RemoteControlClient.PLAYSTATE_PAUSED:
			newState = PlaybackState.STATE_PAUSED;
			break;
		case RemoteControlClient.PLAYSTATE_BUFFERING:
			newState = PlaybackState.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());
	}

	PlaybackState playbackState = builder.build();
	mediaSession.setPlaybackState(playbackState);
	previousState = state;
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:44,代码来源:RemoteControlClientLP.java

示例13: onClientPlaybackStateUpdate

@Override
public void onClientPlaybackStateUpdate(int state, long stateChangeTimeMs, long currentPosMs, float speed) {
    this.isRemoteControllerPlaying = state == RemoteControlClient.PLAYSTATE_PLAYING;
    mHasBug = false;
    if (currentPosMs > 3600000)
        currentPosMs = -1L;
    SharedPreferences current = getSharedPreferences("current_music", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = current.edit();
    editor.putLong("position", currentPosMs);

    if (isRemoteControllerPlaying) {
        long currentTime = System.currentTimeMillis();
        editor.putLong("startTime", currentTime);
    } else {
        NotificationManager notificationManager =
                ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));
        notificationManager.cancel(NOTIFICATION_ID);
        notificationManager.cancel(8);
    }
    editor.putBoolean("playing", isRemoteControllerPlaying);
    editor.apply();

    if (App.isMainActivityVisible() && isRemoteControllerPlaying) {
        Intent internalIntent = new Intent(LyricsViewFragment.UPDATE_LYRICS_ACTION);
        internalIntent
                .putExtra("artist", current.getString("artist", ""))
                .putExtra("track", current.getString("track", ""));
        LyricsViewFragment.sendIntent(NotificationListenerService.this, internalIntent);
    }
    Log.d("geecko", "PlaybackStateUpdate - position stored: " + currentPosMs);

    long position = getRemotePlayerPosition();

    if (durationObject instanceof Double) {
        if (artist != null && !artist.isEmpty())
            mediaControllerCallback.broadcast(this, artist, track, isRemoteControllerPlaying, (Double) durationObject, position, null);
    } else if (durationObject instanceof Integer) {
        if (artist != null && !artist.isEmpty())
            mediaControllerCallback.broadcast(this, artist, track, isRemoteControllerPlaying, (Integer) durationObject, position, null);
    } else if (durationObject instanceof Long)
        if (artist != null && !artist.isEmpty())
            mediaControllerCallback.broadcast(this, artist, track, isRemoteControllerPlaying, (Long) durationObject, position, null);
}
 
开发者ID:QuickLyric,项目名称:QuickLyric,代码行数:43,代码来源:NotificationListenerService.java


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