位置:首页> 开发 > 多媒体 > 浏览文章

在Android应用程序中使用ExoPlayer API进行视频播放

2023-08-23
javaSimpleExoPlayer player = new SimpleExoPlayer.Builder(context).build();

// Create a DASH media source pointing to the URL of the DASH MPD file.
MediaSource mediaSource = new DashMediaSource.Factory(
  new DefaultDataSourceFactory(context, "user-agent"))
  .createMediaSource(Uri.parse("http://example.com/my-stream.mpd"));

// Prepare the player with the source.
player.setMediaSource(mediaSource);
player.prepare();

上述代码创建了一个SimpleExoPlayer实例,使用了一个DashMediaSource对象来指向视频流媒体。 DashMediaSource.Factory接受一个DefaultDataSourceFactory对象,它用于创建数据源。在这个例子中,我们使用了默认的数据源工厂。

首页 上一页 1 2 3 45 6 7 下一页 尾页
下一篇:

相关阅读

热门推荐