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


Java MediaItemStatus类代码示例

本文整理汇总了Java中android.support.v7.media.MediaItemStatus的典型用法代码示例。如果您正苦于以下问题:Java MediaItemStatus类的具体用法?Java MediaItemStatus怎么用?Java MediaItemStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MediaItemStatus类属于android.support.v7.media包,在下文中一共展示了MediaItemStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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