使用CastCompanionLibrary,很容易将 a 发送MediaInfo
到 Chromecast API 来播放它。
MediaInfo.Builder media = new MediaInfo.Builder("http://url.to/video.mp4");
VideoCastManager cast = ...
cast.startVideoCastControllerActivity(context, media.build(), 0, true);
发送多个MediaInfo
s 以创建队列(播放列表)的推荐方法是什么?
更新#1:
我试图将 queueLoad 添加到代码中。让它在startVideoCastControllerActivity
.
MediaInfo.Builder info = new MediaInfo.Builder("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");
info.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED);
info.setContentType("video/mp4");
MediaQueueItem[] items = new MediaQueueItem[] {
new MediaQueueItem.Builder(info.build()).build(),
new MediaQueueItem.Builder(info.build()).build(),
new MediaQueueItem.Builder(info.build()).build()
};
cast.queueLoad(items, 0, 0, null);
它使用此日志使应用程序崩溃:
java.lang.NullPointerException:尝试在 com.google.android 的空对象引用上调用虚拟方法“java.lang.String com.google.android.gms.cast.MediaMetadata.getString(java.lang.String)”。 library.cast.companionlibrary.cast.VideoCastManager.updateMiniController(SourceFile:309) 在 com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.updateMiniControllers(SourceFile:321) 在 com.google.android.libraries.cast。 com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.access$200(SourceFile:136) com.google.android.libraries.cast.companionlibrary.cast 上的companionlibrary.cast.VideoCastManager.onRemoteMediaPlayerStatusUpdated(SourceFile:2126) .VideoCastManager$22.onStatusUpdated(SourceFile:1804) 在 com.google.android.gms.cast.RemoteMediaPlayer。onStatusUpdated(Unknown Source) at com.google.android.gms.cast.RemoteMediaPlayer.zza(Unknown Source) at com.google.android.gms.cast.RemoteMediaPlayer$1.onStatusUpdated(Unknown Source) at com.google.android.gms .cast.internal.zzm.zza(Unknown Source) at com.google.android.gms.cast.internal.zzm.zzbZ(Unknown Source) at com.google.android.gms.cast.RemoteMediaPlayer.onMessageReceived(Unknown Source)在 com.google.android.gms.cast.internal.zze$zzb$4.run(未知来源)onMessageReceived(未知来源)在 com.google.android.gms.cast.internal.zze$zzb$4.run(未知来源)onMessageReceived(未知来源)在 com.google.android.gms.cast.internal.zze$zzb$4.run(未知来源)