我正在创建一个Android应用程序,我想播放以及从BrightCove下载视频现在问题是BrightCove有自己的播放器,即com.brightcove.player.view.BrightcoveExoPlayerVideoView
我无法使用。我必须在Android Native MediaPlayer中播放视频。
我检查了所有文档,并且他们只是一次又一次地提供这样的东西
EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter();
Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy));
catalog.findVideoByID(getString(R.string.videoId), new VideoListener() {
// Add the video found to the queue with add().
// Start playback of the video with start().
@Override
public void onVideo(Video video) {
brightcoveVideoView.add(video);
brightcoveVideoView.start();
}
@Override
public void onError(String s) {
throw new RuntimeException(s);
}
});
我怎样才能获得正确的播放和下载网址?
使用servercalls / API_tester在BrightCove上搜索视频时会返回一些
{" id":1520880903001," name":" Space-Galaxy"," adKeys":null," shortDescription":"用作访问视频内容的示例 媒体API - 不要删除"," longDescription":null,
" creationDate":" 1332264917716"," publishedDate":" 1332264917716",
" lastModifiedDate":" 1441607273772"," linkURL": " http://support.brightcove.com/en/docs/accessing-video-content-media-api&#34 ;, " linkText":"使用Media API访问视频内容","标记":[ " newtag" ]," videoStillURL":" http://brightcove.vo.llnwd.net/e1/pd/57838016001/57838016001_1520916808001_vs-1520911645001.jpg?pubId=57838016001", " thumbnailURL&#34 ;: " http://brightcove.vo.llnwd.net/e1/pd/57838016001/57838016001_1520916809001_th-1520911645001.jpg?pubId=57838016001&#34 ;, " referenceId":" 1520880903001"," length":20000," economic": " AD_SUPPORTED"," playsTotal":102," playsTrailingWeek":0,
" FLVURL&#34 ;: "设rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& MP4:57838016001 / 57838016001_1520916807001_Space-Galaxy.mp4&安培; 1460095200000&安培; a99dcabb0f88cdf8d21b3a5778da8e06&#34 ;, "引渡":[ { " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":800000, " frameHeight":360, " frameWidth":640, " id":1520959065001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":1829449, " uploadTimestampMillis":1332267195355, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520959065001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000 }, { " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":1800000, " frameHeight":720, " frameWidth":1280, " id":1520962209001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":4265519, " uploadTimestampMillis":1332267361480, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520962209001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000 }, { " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":1200000, " frameHeight":404, " frameWidth":720, " id":1520962169001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, " size":2777863, " uploadTimestampMillis":1332267330633, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520962169001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000 }, { " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":314758, " frameHeight":224, " frameWidth":400, " id":1520959023001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":690193, " uploadTimestampMillis":1332267165343, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520959023001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000 }, { " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":500000, " frameHeight":268, " frameWidth":480, " id":1520916807001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":1126642, " uploadTimestampMillis":1332265138822, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520916807001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000 }, { " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":129761, " frameHeight":224, " frameWidth":400, " id":1520953533001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":227983, " uploadTimestampMillis":1332266955420, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520953533001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20134 }]," FLVFullLength":{ " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":500000, " frameHeight":268, " frameWidth":480, " id":1520916807001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":1126642, " uploadTimestampMillis":1332265138822, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520916807001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000}," videoFullLength":{ " audioOnly":false, " controllerType":" DEFAULT", " displayName":" Space-Galaxy.mp4", " encodingRate":500000, " frameHeight":268, " frameWidth":480, " id":1520916807001, " referenceId":null, " remoteStreamName":null, " remoteUrl":null, "尺寸":1126642, " uploadTimestampMillis":1332265138822, " url":" rtmp://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& mp4:57838016001 / 57838016001_1520916807001_Space-Galaxy.mp4& 1460095200000& a99dcabb0f88cdf8d21b3a5778da8e06& #34 ;, " videoCodec":" H264", " videoContainer":" MP4", " videoDuration":20000}}
它有一些像
这样的链接RTMP://brightcove.fcod.llnwd.net/a500/e1/uds/rtmp/ondemand/& MP4:57838016001 / 57838016001_1520959023001_Space-Galaxy.mp4&安培; 1460095200000&安培; a99dcabb0f88cdf8d21b3a5778da8e06
但MediaPlayer上没有播放任何内容。可能是因为rtmp
而对于rmtp
我可能不得不使用Vitamio但我不能因为我被限制使用原生MediaPlayer。
在IOS上我可以使用:BCOVPlaybackService
获取网址但是在android中没有这样的类。
谢谢
答案 0 :(得分:2)
好的,这就是我获取网址的方式
EventEmitter eventEmitter = player.getEventEmitter();
Catalog catalog = new Catalog(eventEmitter, account, privacy);
catalog.findVideoByID(video_brightcove_id, new VideoListener() {
@Override
public void onVideo(Video video) {
Map<DeliveryType, SourceCollection> map = video.getSourceCollections();
Set<DeliveryType> st = map.keySet();
SourceCollection sor = map.get(DeliveryType.valueOf("MP4"));
Set<Source> se = sor.getSources();
Object[] ar = se.toArray();
Source hp = (Source) ar[0];
Map<String, Object> ma = hp.getProperties();
String url = (String) ma.get("url");
////this is the video url
}
@Override
public void onError(String s) {
Log.e("Error ", s);
}
});
谢谢:)