【问题标题】:What is the correct way to extend BrightcovePlayer in Android?在 Android 中扩展 BrightcovePlayer 的正确方法是什么?
【发布时间】:2015-10-28 18:54:34
【问题描述】:

我正在尝试使用 Brightcove Player 播放示例视频。 documentation 建议为播放器实现基本的生命周期回调,应该扩展 BrightcovePlayer 而不是简单的活动。这是我扩展它的方式:

public class BrightCoveActivity extends BrightcovePlayer {

private static final String BC_TOKEN = "<using a valid token here>";
private String mVideoId;

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_bright_cove);
    final BrightcoveVideoView brightcoveVideoView = (BrightcoveVideoView) findViewById(R.id.brightcove_video_view);
    super.onCreate(savedInstanceState);

    final Catalog catalog = new Catalog(BC_TOKEN);

    mVideoId = "<using a valid video ID here";

    MediaController controller = new MediaController(this);
    brightcoveVideoView.setMediaController(controller);

    catalog.findVideoByID(mVideoId, new VideoListener() {

        @Override
        public void onError(String error) {
            throw new RuntimeException(error);

        }

        @Override
        public void onVideo(Video video) {
            brightcoveVideoView.add(video);
            brightcoveVideoView.start();
        }
    });


}

}

但是,当我尝试运行该应用程序时,我不断收到此 IllegalStateException

09-09 17:01:51.988: E/AndroidRuntime(21607): Caused by: java.lang.IllegalStateException: brightcoveVideoView needs to be wired up to the layout.
09-09 17:01:51.988: E/AndroidRuntime(21607):    at com.brightcove.player.view.BrightcovePlayer.onCreate(BrightcovePlayer.java:180)

此堆栈跟踪最终指向super.OnCreate() 方法。在“连接”BrightcoveVideoView 之前或之后调用超类方法都没有区别。

我正在使用:

  1. 一个自定义布局,此时带有 BrightCoveVideoView,除了相对布局内的 videoView 之外没有其他视图。
  2. Eclipse 用于开发(受限于这样做,不能使用 Android Studio)。我已将旧版 .jar 文件作为库包含(如果我在简单的 Activity 而不是 BrightcovePlayer 活动中执行此操作,项目运行良好)。
  3. Brightcove SDK 4.5 适用于 Android。

【问题讨论】:

    标签: android eclipse brightcove


    【解决方案1】:

    你需要在 super.onCreate() 方法之前设置媒体控制器。

    final BrightcoveVideoView brightcoveVideoView = (BrightcoveVideoView)findViewById(R.id.brightcove_video_view);
    MediaController controller = new MediaController(this);
    brightcoveVideoView.setMediaController(controller);
    super.onCreate(savedInstanceState);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-18
      • 2020-02-13
      • 2017-09-14
      • 1970-01-01
      • 2020-09-20
      • 2018-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多