Reply
Visitor
OscarMD
Posts: 2
Registered: ‎07-03-2011
0 Kudos

[Android] Video player issues

Hello. We've been developing an app that uses the BrightCove API and for the past couple of days I've been trying to get a standalone player(based on an example I found here in the forum), that receives our client's token and a single video ID, to play correctly, but so far I've had no luck. I was hoping someone here could help me out. The player launches correctly, it displays the video's length and starts playing but the image freezes. You can hear the audio, but it's constantly interrupted, I'm guessing because it's loading. Here's the code:

 

package com.brightcove;

import java.util.EnumSet;
import java.util.logging.Logger;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

import com.brightcove.R;
import com.brightcove.mobile.android.BCPlayerView;
import com.brightcove.mobile.mediaapi.ReadAPI;
import com.brightcove.mobile.mediaapi.model.Video;
import com.brightcove.mobile.mediaapi.model.enums.MediaDeliveryTypeEnum;
import com.brightcove.mobile.mediaapi.model.enums.RegionEnum;
import com.brightcove.mobile.mediaapi.model.enums.VideoFieldEnum;


public class BcPlayer extends Activity {
	
	public final static String API_TOKEN = "TOKEN GOES HERE"; // API Token Goes Here
	
	private static final String TAG = "Player";
	
	public static final long VIDEO_ID = "VIDEO ID GOES HERE"; // Video ID Goes Here;
	
	private BCPlayerView player;
        private int lowBitRate = 200000;
        private int highBitRate = 200000;


	@Override
	protected 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.player);

    	player = (BCPlayerView) findViewById(R.id.player);
		
    	playVideo();
	}
	
    
    private void playVideo() {
    	
        if (player == null) {
            Log.e("BCPlaybackTester.playVideo", "No player found.  Giving up.");
            return;
        }
        
        EnumSet<VideoFieldEnum> videoFields = VideoFieldEnum.createEmptyEnumSet();
        videoFields.add(VideoFieldEnum.ID);
        videoFields.add(VideoFieldEnum.NAME);
        videoFields.add(VideoFieldEnum.RENDITIONS);
        videoFields.add(VideoFieldEnum.FLVURL);


        Logger log = Logger.getLogger("BCAndroidAPILogger");
        ReadAPI readAPI = new ReadAPI(API_TOKEN);
        readAPI.setLogger(log);
        readAPI.setMediaDeliveryType(MediaDeliveryTypeEnum.HTTP);
	readAPI.setRegion(RegionEnum.US);

        try {
            Video video = readAPI.findVideoById(VIDEO_ID , videoFields, null);
            
            if (video != null) {
            	player.logEnabled(true);
                player.load(video);
                player.setRenditionBitRateRange(lowBitRate, highBitRate);
                player.start();
            } else {
                Log.e("BCPlaybackTester.playVideo", "No video found for id: " + VIDEO_ID);
            }
        } catch (Exception e) {
            Log.e(TAG, "error in temp code", e);
        }
    }
}

I tried setting the setRenditionBitRateRange to the lowest after tracing the low(200000) and high(500000) bit rates in Logcat, but I'm not sure I'm doing it correctly. I also checked that it was returning H.264 videos, which it does. Maybe it's got something to do with the emulator, maybe not. I really have no idea what else to look for.

 

Any help would be greatly appreciated.

 

Moderator
BC-Erika
Posts: 185
Registered: ‎12-09-2008
0 Kudos

Re: [Android] Video player issues

Hi Oscar,

 

Your low and high bitrate is exactly 200000 which doesn't allow much room to find a rendition. Can you try widening that just a little, maybe 100000 and 250000??

 

What's the video ID you're loading?

 

Also, after trying that, can you tell us the logcat error you're getting?

 

Erika