本文整理汇总了Java中com.google.android.gms.cast.framework.media.RemoteMediaClient类的典型用法代码示例。如果您正苦于以下问题:Java RemoteMediaClient类的具体用法?Java RemoteMediaClient怎么用?Java RemoteMediaClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteMediaClient类属于com.google.android.gms.cast.framework.media包,在下文中一共展示了RemoteMediaClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playFiles
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
@Override
public void playFiles(List<MediaQueueItem> mediaItems) {
CastSession castSession =
CastContext.getSharedInstance(this).getSessionManager().getCurrentCastSession();
if (castSession == null) {
Toast.makeText(this, "Not connected", Toast.LENGTH_LONG).show();
return;
}
// For variety, shuffle the list.
Collections.shuffle(mediaItems);
Log.d(TAG, "playFiles: sending " + mediaItems.size() + " files to Chromecast");
RemoteMediaClient mediaClient = castSession.getRemoteMediaClient();
int startIndex = 0;
mediaClient.queueLoad(mediaItems.toArray(new MediaQueueItem[0]), startIndex,
MediaStatus.REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE, null);
}
示例2: removeAll
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
public void removeAll() {
synchronized (mLock) {
if (mQueue.isEmpty()) {
return;
}
RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
if (remoteMediaClient == null) {
return;
}
int[] itemIds = new int[mQueue.size()];
for (int i = 0; i < mQueue.size(); i++) {
itemIds[i] = mQueue.get(i).getItemId();
}
remoteMediaClient.queueRemoveItems(itemIds, null);
mQueue.clear();
}
}
示例3: syncWithRemoteQueue
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private void syncWithRemoteQueue() {
RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
if (remoteMediaClient != null) {
remoteMediaClient.addListener(mRemoteMediaClientListener);
MediaStatus mediaStatus = remoteMediaClient.getMediaStatus();
if (mediaStatus != null) {
List<MediaQueueItem> items = mediaStatus.getQueueItems();
if (items != null && !items.isEmpty()) {
mQueue.clear();
mQueue.addAll(items);
mRepeatMode = mediaStatus.getQueueRepeatMode();
mCurrentIem = mediaStatus.getQueueItemById(mediaStatus.getCurrentItemId());
mDetachedQueue = false;
mUpcomingItem = mediaStatus.getQueueItemById(mediaStatus.getPreloadedItemId());
}
}
}
}
示例4: onPreloadStatusUpdated
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
@Override
public void onPreloadStatusUpdated() {
RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
if (remoteMediaClient == null) {
return;
}
MediaStatus mediaStatus = remoteMediaClient.getMediaStatus();
if (mediaStatus == null) {
return;
}
mUpcomingItem = mediaStatus.getQueueItemById(mediaStatus.getPreloadedItemId());
Log.d(TAG, "onRemoteMediaPreloadStatusUpdated() with item=" + mUpcomingItem);
if (mListener != null) {
mListener.onQueueDataChanged();
}
}
示例5: updateMediaQueue
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private void updateMediaQueue() {
RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
MediaStatus mediaStatus;
List<MediaQueueItem> queueItems = null;
if (remoteMediaClient != null) {
mediaStatus = remoteMediaClient.getMediaStatus();
if (mediaStatus != null) {
queueItems = mediaStatus.getQueueItems();
mRepeatMode = mediaStatus.getQueueRepeatMode();
mCurrentIem = mediaStatus.getQueueItemById(mediaStatus.getCurrentItemId());
}
}
mQueue.clear();
if (queueItems == null) {
Log.d(TAG, "Queue is cleared");
} else {
Log.d(TAG, "Queue is updated with a list of size: " + queueItems.size());
if (queueItems.size() > 0) {
mQueue.addAll(queueItems);
mDetachedQueue = false;
} else {
mDetachedQueue = true;
}
}
}
示例6: updatePlayPauseButtonImageResource
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private void updatePlayPauseButtonImageResource(ImageButton button) {
CastSession castSession = CastContext.getSharedInstance(mAppContext)
.getSessionManager().getCurrentCastSession();
RemoteMediaClient remoteMediaClient =
(castSession == null) ? null : castSession.getRemoteMediaClient();
if (remoteMediaClient == null) {
button.setVisibility(View.GONE);
return;
}
int status = remoteMediaClient.getPlayerState();
switch (status) {
case MediaStatus.PLAYER_STATE_PLAYING:
button.setImageResource(PAUSE_RESOURCE);
break;
case MediaStatus.PLAYER_STATE_PAUSED:
button.setImageResource(PLAY_RESOURCE);
break;
default:
button.setVisibility(View.GONE);
}
}
示例7: PlayRemote
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
public static void PlayRemote(String title, String url, String iconurl){
Log.i("CAST",title);
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
movieMetadata.putString(MediaMetadata.KEY_TITLE, title);
//movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, "MySubTitle");
movieMetadata.addImage(new WebImage(Uri.parse(iconurl)));
//movieMetadata.addImage(new WebImage(Uri.parse(mSelectedMedia.getImage(1))));
MediaInfo mediaInfo = new MediaInfo.Builder(url)
.setStreamType(MediaInfo.STREAM_TYPE_LIVE)
.setContentType("audio/ogg")
.setMetadata(movieMetadata)
//.setStreamDuration(mSelectedMedia.getDuration() * 1000)
.build();
RemoteMediaClient remoteMediaClient = mCastSession.getRemoteMediaClient();
remoteMediaClient.load(mediaInfo, true);
}
示例8: play
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
public void play() {
if (!hasMediaSession(true)) {
return;
}
LOGD(TAG, "Start PLAY");
if (isEnded) {
load(0, mEntryName, mEntryDescription , mEntryThumbnailUrl, mEntryId);
stopTimer();
startTimer();
updateState(State.Playing);
return;
}
mCastSession.getRemoteMediaClient().play().setResultCallback(new ResultCallback<RemoteMediaClient.MediaChannelResult>() {
@Override
public void onResult(@NonNull RemoteMediaClient.MediaChannelResult mediaChannelResult) {
if (!mediaChannelResult.getStatus().isSuccess()) {
LOGE(TAG, "CC Play failed");
sendError("CC Play failed", null);
} else {
startTimer();
updateState(State.Playing);
}
}
});
}
示例9: pause
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
public void pause() {
if (!hasMediaSession(true)) {
return;
}
LOGD(TAG, "Start PAUSE");
mCastSession.getRemoteMediaClient().pause().setResultCallback(new ResultCallback<RemoteMediaClient.MediaChannelResult>() {
@Override
public void onResult(@NonNull RemoteMediaClient.MediaChannelResult mediaChannelResult) {
if (!mediaChannelResult.getStatus().isSuccess()) {
LOGE(TAG, "CC Pause failed");
sendError("CC Pause failed", null);
} else {
updateState(State.Pause);
}
}
});
stopTimer();
}
示例10: seek
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
public void seek(long currentPosition) {
if (!hasMediaSession(true)) {
return;
}
LOGD(TAG, "CC seek to " + currentPosition);
LOGD(TAG, "CC SEND SEEKING");
updateState(State.Seeking);
mCastSession.getRemoteMediaClient().seek(currentPosition).setResultCallback(new ResultCallback<RemoteMediaClient.MediaChannelResult>() {
@Override
public void onResult(@NonNull RemoteMediaClient.MediaChannelResult mediaChannelResult) {
if (!mediaChannelResult.getStatus().isSuccess()) {
LOGE(TAG, "CC Seek to currentPosition failed");
sendError("CC Seek failed", null);
} else {
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
LOGD(TAG, "CC SEND SEEKED");
updateState(State.Seeked);
}
}, 2500);
}
}
});
}
示例11: setStreamVolume
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
@Override
public void setStreamVolume(double streamVolume) {
if (!hasMediaSession(true)) {
return;
}
LOGD(TAG, "CC setStreamVolume " + streamVolume);
mCastSession.getRemoteMediaClient().setStreamVolume(streamVolume).setResultCallback(new ResultCallback<RemoteMediaClient.MediaChannelResult>() {
@Override
public void onResult(@NonNull RemoteMediaClient.MediaChannelResult mediaChannelResult) {
if (!mediaChannelResult.getStatus().isSuccess()) {
LOGE(TAG, "CC setStreamVolume failed");
sendError("CC setStreamVolume failed", null);
} else {
updateState(State.VolumeChanged);
}
}
});
}
示例12: castMedia
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private void castMedia() {
if (castSession != null) {
MediaMetadata audioMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
String url = "http://" + Helpers.getIpAddress(MediaRecorderService.this) + ":" + StreamHttpServer.HTTP_SERVER_PORT + StreamHttpServer.HTTP_SERVER_URL_PATH;
MediaInfo mediaInfo = new MediaInfo.Builder(url)
.setStreamType(MediaInfo.STREAM_TYPE_LIVE)
.setContentType("audio/aac")
.setMetadata(audioMetadata)
.build();
Log.d(TAG, "MediaInfo: " + mediaInfo);
RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient();
remoteMediaClient.load(mediaInfo);
}
}
示例13: isRemoteVideoPlaying
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private boolean isRemoteVideoPlaying() {
if (castSession != null) {
RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient();
return remoteMediaClient.isPlaying();
}
return false;
}
示例14: resumeRemoteVideo
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private void resumeRemoteVideo() {
if (castSession != null) {
RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient();
if (remoteMediaClient != null) {
remoteMediaClient.play();
}
}
}
示例15: pauseRemoteVideo
import com.google.android.gms.cast.framework.media.RemoteMediaClient; //导入依赖的package包/类
private void pauseRemoteVideo() {
if (castSession != null) {
RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient();
if (remoteMediaClient != null) {
remoteMediaClient.pause();
}
}
}