本文整理汇总了Java中android.support.v7.media.MediaItemStatus类的典型用法代码示例。如果您正苦于以下问题:Java MediaItemStatus类的具体用法?Java MediaItemStatus怎么用?Java MediaItemStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaItemStatus类属于android.support.v7.media包,在下文中一共展示了MediaItemStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: seek
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
public PlaylistItem seek(String iid, long pos) {
if (DEBUG) {
log("seek: iid=" + iid +", pos=" + pos);
}
checkPlayerAndSession();
// seeking on pending items are not yet supported
checkItemCurrent(iid);
PlaylistItem item = getCurrentItem();
if (pos != item.getPosition()) {
item.setPosition(pos);
if (item.getState() == MediaItemStatus.PLAYBACK_STATE_PLAYING
|| item.getState() == MediaItemStatus.PLAYBACK_STATE_PAUSED) {
mPlayer.seek(item);
}
}
return item;
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:19,代码来源:SessionManager.java
示例2: updatePlaybackState
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void updatePlaybackState() {
PlaylistItem item = getCurrentItem();
if (item != null) {
if (item.getState() == MediaItemStatus.PLAYBACK_STATE_PENDING) {
item.setState(mPaused ? MediaItemStatus.PLAYBACK_STATE_PAUSED
: MediaItemStatus.PLAYBACK_STATE_PLAYING);
if (!mPlayer.isQueuingSupported()) {
mPlayer.play(item);
}
} else if (mPaused && item.getState() == MediaItemStatus.PLAYBACK_STATE_PLAYING) {
mPlayer.pause();
item.setState(MediaItemStatus.PLAYBACK_STATE_PAUSED);
} else if (!mPaused && item.getState() == MediaItemStatus.PLAYBACK_STATE_PAUSED) {
mPlayer.resume();
item.setState(MediaItemStatus.PLAYBACK_STATE_PLAYING);
}
// notify client that item playback status has changed
if (mCallback != null) {
mCallback.onItemChanged(item);
}
}
updateStatus();
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:24,代码来源:SessionManager.java
示例3: updateProgress
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void updateProgress() {
// Estimate content position from last status time and elapsed time.
// (Note this might be slightly out of sync with remote side, however
// it avoids frequent polling the MRP.)
int progress = 0;
PlaylistItem item = getCheckedPlaylistItem();
if (item != null) {
int state = item.getState();
long duration = item.getDuration();
if (duration <= 0) {
if (state == MediaItemStatus.PLAYBACK_STATE_PLAYING
|| state == MediaItemStatus.PLAYBACK_STATE_PAUSED) {
mSessionManager.updateStatus();
}
} else {
long position = item.getPosition();
long timeDelta = mSessionManager.isPaused() ? 0 :
(SystemClock.elapsedRealtime() - item.getTimestamp());
progress = (int)(100.0 * (position + timeDelta) / duration);
}
}
mSeekBar.setProgress(progress);
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:24,代码来源:SampleMediaRouterActivity.java
示例4: getStatus
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void getStatus(String itemId, String sessionId, ControlRequestCallback callback) {
if (callback == null)
return;
Bundle status = null;
if (mItemId.equals(itemId)) {
status = new MediaItemStatus.Builder(mState)
.setContentPosition(mPlayer.getCurrentPosition())
.setContentDuration(mPlayer.getDuration())
.setTimestamp(SystemClock.elapsedRealtime())
.build()
.asBundle();
status.putString(MediaControlIntent.EXTRA_SESSION_ID, mRouteId);
status.putString(MediaControlIntent.EXTRA_ITEM_ID, mItemId);
}
else {
status = new MediaItemStatus.Builder(MediaItemStatus.PLAYBACK_STATE_INVALIDATED)
.build().asBundle();
}
callback.onResult(status);
}
开发者ID:Nutomic,项目名称:controldlna,代码行数:25,代码来源:Controller.java
示例5: logExtraHttpInfo
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
@RemovableInRelease
private void logExtraHttpInfo(Bundle extras) {
if (extras != null) {
if (extras.containsKey(MediaItemStatus.EXTRA_HTTP_STATUS_CODE)) {
int httpStatus = extras.getInt(MediaItemStatus.EXTRA_HTTP_STATUS_CODE);
Log.d(TAG, "HTTP status: %s", httpStatus);
}
if (extras.containsKey(MediaItemStatus.EXTRA_HTTP_RESPONSE_HEADERS)) {
Bundle headers = extras.getBundle(MediaItemStatus.EXTRA_HTTP_RESPONSE_HEADERS);
Log.d(TAG, "HTTP headers: %s", bundleToString(headers));
}
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:DefaultMediaRouteController.java
示例6: setPlayerStateForMediaItemState
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
@VisibleForTesting
void setPlayerStateForMediaItemState(int state) {
PlayerState playerState = PlayerState.STOPPED;
switch (state) {
case MediaItemStatus.PLAYBACK_STATE_BUFFERING:
playerState = PlayerState.LOADING;
break;
case MediaItemStatus.PLAYBACK_STATE_CANCELED:
playerState = PlayerState.FINISHED;
break;
case MediaItemStatus.PLAYBACK_STATE_ERROR:
playerState = PlayerState.ERROR;
break;
case MediaItemStatus.PLAYBACK_STATE_FINISHED:
playerState = PlayerState.FINISHED;
break;
case MediaItemStatus.PLAYBACK_STATE_INVALIDATED:
playerState = PlayerState.INVALIDATED;
break;
case MediaItemStatus.PLAYBACK_STATE_PAUSED:
if (isAtEndOfVideo(getPosition(), getDuration())) {
playerState = PlayerState.FINISHED;
} else {
playerState = PlayerState.PAUSED;
}
break;
case MediaItemStatus.PLAYBACK_STATE_PENDING:
playerState = PlayerState.PAUSED;
break;
case MediaItemStatus.PLAYBACK_STATE_PLAYING:
playerState = PlayerState.PLAYING;
break;
default:
break;
}
mRemotePlayerState = playerState;
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:39,代码来源:AbstractMediaRouteController.java
示例7: type
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
public static SubjectFactory<MediaItemStatusSubject, MediaItemStatus> type() {
return new SubjectFactory<MediaItemStatusSubject, MediaItemStatus>() {
@Override
public MediaItemStatusSubject getSubject(FailureStrategy fs, MediaItemStatus that) {
return new MediaItemStatusSubject(fs, that);
}
};
}
开发者ID:pkware,项目名称:truth-android,代码行数:9,代码来源:MediaItemStatusSubject.java
示例8: setPlayerStateForMediaItemState
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
@VisibleForTesting
void setPlayerStateForMediaItemState(int state) {
PlayerState playerState = PlayerState.STOPPED;
switch (state) {
case MediaItemStatus.PLAYBACK_STATE_BUFFERING:
playerState = PlayerState.LOADING;
break;
case MediaItemStatus.PLAYBACK_STATE_CANCELED:
playerState = PlayerState.FINISHED;
break;
case MediaItemStatus.PLAYBACK_STATE_ERROR:
playerState = PlayerState.ERROR;
break;
case MediaItemStatus.PLAYBACK_STATE_FINISHED:
playerState = PlayerState.FINISHED;
break;
case MediaItemStatus.PLAYBACK_STATE_INVALIDATED:
playerState = PlayerState.INVALIDATED;
break;
case MediaItemStatus.PLAYBACK_STATE_PAUSED:
if (isAtEndOfVideo(getPosition(), getDuration())) {
playerState = PlayerState.FINISHED;
} else {
playerState = PlayerState.PAUSED;
}
break;
case MediaItemStatus.PLAYBACK_STATE_PENDING:
playerState = PlayerState.PAUSED;
break;
case MediaItemStatus.PLAYBACK_STATE_PLAYING:
playerState = PlayerState.PLAYING;
break;
default:
break;
}
mPlaybackState = playerState;
}
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:39,代码来源:AbstractMediaRouteController.java
示例9: onItemStatusChanged
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
@Override
public void onItemStatusChanged(Bundle data,
String sessionId, MediaSessionStatus sessionStatus,
String itemId, MediaItemStatus itemStatus) {
logStatus("onItemStatusChanged", sessionId, sessionStatus, itemId, itemStatus);
if (mCallback != null) {
if (itemStatus.getPlaybackState() ==
MediaItemStatus.PLAYBACK_STATE_FINISHED) {
mCallback.onCompletion();
} else if (itemStatus.getPlaybackState() ==
MediaItemStatus.PLAYBACK_STATE_ERROR) {
mCallback.onError();
}
}
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:16,代码来源:RemotePlayer.java
示例10: logStatus
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void logStatus(String message,
String sessionId, MediaSessionStatus sessionStatus,
String itemId, MediaItemStatus itemStatus) {
if (DEBUG) {
String result = "";
if (sessionId != null && sessionStatus != null) {
result += "sessionId=" + sessionId + ", sessionStatus=" + sessionStatus;
}
if (itemId != null & itemStatus != null) {
result += (result.isEmpty() ? "" : ", ")
+ "itemId=" + itemId + ", itemStatus=" + itemStatus;
}
Log.d(TAG, message + ": " + result);
}
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:16,代码来源:RemotePlayer.java
示例11: remove
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
public PlaylistItem remove(String iid) {
if (DEBUG) {
log("remove: iid=" + iid);
}
checkPlayerAndSession();
return removeItem(iid, MediaItemStatus.PLAYBACK_STATE_CANCELED);
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:8,代码来源:SessionManager.java
示例12: removeItem
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private PlaylistItem removeItem(String iid, int state) {
checkPlayerAndSession();
List<PlaylistItem> queue =
new ArrayList<PlaylistItem>(mPlaylist.size());
PlaylistItem found = null;
for (PlaylistItem item : mPlaylist) {
if (iid.equals(item.getItemId())) {
if (mPlayer.isQueuingSupported()) {
mPlayer.remove(item.getRemoteItemId());
} else if (item.getState() == MediaItemStatus.PLAYBACK_STATE_PLAYING
|| item.getState() == MediaItemStatus.PLAYBACK_STATE_PAUSED){
mPlayer.stop();
}
item.setState(state);
found = item;
// notify client that item is now removed
if (mCallback != null) {
mCallback.onItemChanged(found);
}
} else {
queue.add(item);
}
}
if (found != null) {
mPlaylist = queue;
updatePlaybackState();
} else {
log("item not found");
}
return found;
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:32,代码来源:SessionManager.java
示例13: finishItem
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void finishItem(boolean error) {
PlaylistItem item = getCurrentItem();
if (item != null) {
removeItem(item.getItemId(), error ?
MediaItemStatus.PLAYBACK_STATE_ERROR :
MediaItemStatus.PLAYBACK_STATE_FINISHED);
updateStatus();
}
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:10,代码来源:SessionManager.java
示例14: getStatus
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
public MediaItemStatus getStatus() {
return new MediaItemStatus.Builder(mPlaybackState)
.setContentPosition(mContentPosition)
.setContentDuration(mContentDuration)
.setTimestamp(mTimestamp)
.build();
}
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:8,代码来源:PlaylistItem.java
示例15: onPrepared
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
/**
* Starts playback and sets completion listener.
*/
@Override
public void onPrepared(MediaPlayer mp) {
mPlayer.start();
mState = MediaItemStatus.PLAYBACK_STATE_PLAYING;
mPlayer.setOnCompletionListener(this);
}
开发者ID:Nutomic,项目名称:controldlna,代码行数:10,代码来源:Controller.java
示例16: receivePlaybackStatus
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
/**
* Receives information from MediaRouterPlayService about playback status.
*/
public void receivePlaybackStatus(MediaItemStatus status) {
// Views may not exist if fragment was just created/destroyed.
if (getView() == null)
return;
int currentTime = (int) status.getContentPosition() / 1000;
int totalTime = (int) status.getContentDuration() / 1000;
mCurrentTimeView.setText(generateTimeString(currentTime));
mTotalTimeView.setText(generateTimeString(totalTime));
mProgressBar.setProgress(currentTime);
mProgressBar.setMax(totalTime);
if (status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_PLAYING ||
status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_BUFFERING ||
status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_PENDING) {
changePlayPauseState(true);
}
else {
changePlayPauseState(false);
}
if (mListView.getAdapter() == mPlaylistAdapter) {
enableTrackHighlight();
}
}
开发者ID:Nutomic,项目名称:controldlna,代码行数:31,代码来源:RouteFragment.java
示例17: processMediaStatusBundle
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void processMediaStatusBundle(Bundle statusBundle) {
if (statusBundle == null) return;
logBundle("processMediaStatusBundle: ", statusBundle);
String itemId = statusBundle.getString(MediaControlIntent.EXTRA_ITEM_ID);
if (itemId == null || !itemId.equals(mCurrentItemId)) return;
// Extract item metadata, if available.
if (statusBundle.containsKey(MediaControlIntent.EXTRA_ITEM_METADATA)) {
Bundle metadataBundle =
(Bundle) statusBundle.getParcelable(MediaControlIntent.EXTRA_ITEM_METADATA);
updateTitle(metadataBundle.getString(MediaItemMetadata.KEY_TITLE, mPreferredTitle));
}
// Extract the item status, if available.
if (statusBundle.containsKey(MediaControlIntent.EXTRA_ITEM_STATUS)) {
Bundle itemStatusBundle =
(Bundle) statusBundle.getParcelable(MediaControlIntent.EXTRA_ITEM_STATUS);
MediaItemStatus itemStatus = MediaItemStatus.fromBundle(itemStatusBundle);
logBundle("Received item status: ", itemStatusBundle);
updateState(itemStatus.getPlaybackState());
// Update the PositionExtrapolator that the playback state has changed.
if (itemStatus.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_PLAYING) {
mPositionExtrapolator.onResumed();
} else if (itemStatus.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_FINISHED) {
mPositionExtrapolator.onFinished();
} else {
mPositionExtrapolator.onPaused();
}
if ((getRemotePlayerState() == PlayerState.PAUSED)
|| (getRemotePlayerState() == PlayerState.PLAYING)
|| (getRemotePlayerState() == PlayerState.LOADING)) {
this.mCurrentItemId = itemId;
// duration can possibly be -1 if it's unknown, so cap to 0
long duration = Math.max(itemStatus.getContentDuration(), 0);
// update the position using the remote player's position
// duration can possibly be -1 if it's unknown, so cap to 0
long position = Math.min(Math.max(itemStatus.getContentPosition(), 0), duration);
// TODO(zqzhang): The GMS core currently uses SystemClock.uptimeMillis() as
// timestamp, which does not conform to the MediaRouter support library docs. See
// b/28378525 and
// http://developer.android.com/reference/android/support/v7/media/MediaItemStatus.html#getTimestamp().
// Override the timestamp with elapsedRealtime() by assuming the delay between the
// GMS core produces the MediaItemStatus and the code reaches here is short enough.
// long timestamp = itemStatus.getTimestamp();
long timestamp = SystemClock.elapsedRealtime();
notifyDurationUpdated(duration);
notifyPositionUpdated(position);
mPositionExtrapolator.onPositionInfoUpdated(duration, position, timestamp);
if (mSeeking) {
mSeeking = false;
if (getMediaStateListener() != null) getMediaStateListener().onSeekCompleted();
}
}
logExtraHttpInfo(itemStatus.getExtras());
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:64,代码来源:DefaultMediaRouteController.java
示例18: MediaItemStatusSubject
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
protected MediaItemStatusSubject(FailureStrategy failureStrategy, MediaItemStatus subject) {
super(failureStrategy, subject);
}
开发者ID:pkware,项目名称:truth-android,代码行数:4,代码来源:MediaItemStatusSubject.java
示例19: processMediaStatusBundle
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
private void processMediaStatusBundle(Bundle statusBundle) {
if (statusBundle == null) return;
if (mDebug) Log.d(TAG, "processMediaStatusBundle: " + bundleToString(statusBundle));
String itemId = statusBundle.getString(MediaControlIntent.EXTRA_ITEM_ID);
if (itemId == null || !itemId.equals(mCurrentItemId)) return;
// Extract item metadata, if available.
if (statusBundle.containsKey(MediaControlIntent.EXTRA_ITEM_METADATA)) {
Bundle metadataBundle =
(Bundle) statusBundle.getParcelable(MediaControlIntent.EXTRA_ITEM_METADATA);
updateTitle(metadataBundle.getString(MediaItemMetadata.KEY_TITLE));
}
// Extract the item status, if available.
if (statusBundle.containsKey(MediaControlIntent.EXTRA_ITEM_STATUS)) {
Bundle itemStatusBundle =
(Bundle) statusBundle.getParcelable(MediaControlIntent.EXTRA_ITEM_STATUS);
MediaItemStatus itemStatus = MediaItemStatus.fromBundle(itemStatusBundle);
if (mDebug) Log.d(TAG, "Received item status: " + bundleToString(itemStatusBundle));
updateState(itemStatus.getPlaybackState());
if ((getPlayerState() == PlayerState.PAUSED)
|| (getPlayerState() == PlayerState.PLAYING)
|| (getPlayerState() == PlayerState.LOADING)) {
this.mCurrentItemId = itemId;
int duration = (int) itemStatus.getContentDuration();
// duration can possibly be -1 if it's unknown, so cap to 0
updateDuration(Math.max(duration, 0));
// update the position using the remote player's position
mLastKnownStreamPosition = (int) itemStatus.getContentPosition();
mStreamPositionTimestamp = (int) itemStatus.getTimestamp();
updatePosition();
if (mSeeking) {
mSeeking = false;
if (getMediaStateListener() != null) getMediaStateListener().onSeekCompleted();
}
}
Bundle extras = itemStatus.getExtras();
if (mDebug && extras != null) {
if (extras.containsKey(MediaItemStatus.EXTRA_HTTP_STATUS_CODE)) {
int httpStatus = extras.getInt(MediaItemStatus.EXTRA_HTTP_STATUS_CODE);
Log.d(TAG, "HTTP status: " + httpStatus);
}
if (extras.containsKey(MediaItemStatus.EXTRA_HTTP_RESPONSE_HEADERS)) {
Bundle headers = extras.getBundle(MediaItemStatus.EXTRA_HTTP_RESPONSE_HEADERS);
Log.d(TAG, "HTTP headers: " + headers);
}
}
}
}
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:60,代码来源:DefaultMediaRouteController.java
示例20: onControlRequest
import android.support.v7.media.MediaItemStatus; //导入依赖的package包/类
@Override
public boolean onControlRequest(Intent intent, ControlRequestCallback callback) {
Log.d(TAG, mRouteId + ": Received control request " + intent);
if (intent.getAction().equals(MediaControlIntent.ACTION_PLAY)
&& intent.hasCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
&& intent.getData() != null) {
mPlaybackCount +=1;
// TODO: Handle queue ids.
Uri uri = intent.getData();
long contentPositionMillis = intent.getLongExtra(
MediaControlIntent.EXTRA_ITEM_CONTENT_POSITION, 0);
Bundle metadata = intent.getBundleExtra(MediaControlIntent.EXTRA_ITEM_METADATA);
Bundle headers = intent.getBundleExtra(
MediaControlIntent.EXTRA_ITEM_HTTP_HEADERS);
Log.d(TAG, mRouteId + ": Received play request, uri=" + uri
+ ", contentPositionMillis=" + contentPositionMillis
+ ", metadata=" + metadata
+ ", headers=" + headers);
if (uri.toString().contains("hats")) {
// Simulate generating an error whenever the uri contains the word 'hats'.
Toast.makeText(getContext(), "Route rejected play request: uri=" + uri
+ ", no hats allowed!", Toast.LENGTH_LONG).show();
if (callback != null) {
callback.onError("Simulated error. No hats allowed!", null);
}
} else {
Toast.makeText(getContext(), "Route received play request: uri=" + uri,
Toast.LENGTH_LONG).show();
String streamId = generateStreamId();
if (callback != null) {
MediaItemStatus status = new MediaItemStatus.Builder(
MediaItemStatus.PLAYBACK_STATE_PLAYING)
.setContentPosition(contentPositionMillis)
.build();
Bundle result = new Bundle();
result.putString(MediaControlIntent.EXTRA_ITEM_ID, streamId);
result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS, status.asBundle());
callback.onResult(result);
}
}
return true;
}
if (intent.getAction().equals(ACTION_GET_STATISTICS)
&& intent.hasCategory(CATEGORY_SAMPLE_ROUTE)) {
Bundle data = new Bundle();
data.putInt(DATA_PLAYBACK_COUNT, mPlaybackCount);
if (callback != null) {
callback.onResult(data);
}
return true;
}
return false;
}
开发者ID:reknih,项目名称:informant-droid,代码行数:59,代码来源:SampleMediaRouteProvider.java
注:本文中的android.support.v7.media.MediaItemStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论