Reputation: 2620
I just wanna implement Brightcove player in android.i referred from
http://support.brightcove.com/en/docs/accessing-video-content-media-api
http://support.brightcove.com/en/docs/best-practices-android-app-development
From that., i got video url as " http://api.brightcove.com/services/library?command=find_video_by_id&video_id=1520880903001&video_fields=name,length,FLVURL&media_delivery=http&token=jskS1rEtQHy9exQKoc14IcMq8v5x2gCP6yaB7d0hraRtO__6HUuxMg.. "
On tht i got VideoId,Video_fields for a particular video on videocloud.I just want to play that video using those informations on brightcove player in android native app.
My code:
private static final String MyApiToken = "My Token"; private ReadAPI mReadAPI = new ReadAPI(MyApiToken); private com.brightcove.mobile.mediaapi.model.Video pVideo;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
makeAPICall();
}
private void makeAPICall() {
Log.d("Sample", "Beginning makeAPICall");
EnumSet<VideoFieldEnum> videoFields = VideoFieldEnum.createEmptyEnumSet();
videoFields.add(VideoFieldEnum.NAME);
videoFields.add(VideoFieldEnum.LENGTH);
videoFields.add(VideoFieldEnum.FLVURL);
try {
long videoId =My videoId;
pVideo = mReadAPI.findVideoById(videoId, videoFields, null);
} catch(Exception e) {
String msg = e.getMessage();
Log.e("Sample", msg);
}
//Create the player
BCPlayerView mPlayer;
mPlayer = (BCPlayerView) findViewById(R.id.player);
mPlayer.load(pVideo);
mPlayer.start();
}
}
Ive added library jars like bc-android-mediapi.jar & bc-android-player.jar also.When i tried to run.,I got black screen with video player controller visible.But video is not playing.Anything i need to include further?
Thanks.
Upvotes: 1
Views: 1434
Reputation: 7463
I know this is an old post, but I stubbled on it while searching for the same answer.
Here is how I solved it:
Make sure that your app has permission to access the Internet
<uses-permission android:name="android.permission.INTERNET"/>
Using the Read API token key with URL Access (How to get this token)
By forcing the media delivery type to be H264
theReadAPI.setMediaDeliveryType(MediaDeliveryTypeEnum.HTTP);
Hope this helps anyone else having problems with this library. Here is my full code sample:
Logger mAPILogger = Logger.getLogger("BCAndroidAPILogger");
ReadAPI theReadAPI = new ReadAPI("read with URL Access token");
theReadAPI.setMediaDeliveryType(MediaDeliveryTypeEnum.HTTP);
theReadAPI.setLogger(mAPILogger);
EnumSet<VideoFieldEnum> videoFields = VideoFieldEnum
.createEmptyEnumSet();
videoFields.add(VideoFieldEnum.ID);
videoFields.add(VideoFieldEnum.NAME);
videoFields.add(VideoFieldEnum.LENGTH);
videoFields.add(VideoFieldEnum.RENDITIONS);
videoFields.add(VideoFieldEnum.FLVURL);
videoFields.add(VideoFieldEnum.THUMBNAILURL);
videoFields.add(VideoFieldEnum.VIDEOFULLLENGTH);
try {
// Get My Playlist
Playlist thePlaylist = theReadAPI.findPlaylistById(1234567890123,
videoFields, null, null);
BCPlayerView thePlayer = (BCPlayerView) findViewById(R.id.player);
thePlayer.logEnabled(true);
thePlayer.load(thePlaylist.getVideos().get(0));
thePlayer.start();
} catch (Exception e) {
e.printStackTrace();
}
Upvotes: 2