ExoPlayer 2.18.2 基本使用(一)
一份官方的ExoPlayer使用指南
官方使用教程
注意!是全英文的教程
基本使用
这里以播放mp4文件为例
- xml布局添加播放器界面
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.exoplayer2.ui.StyledPlayerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/player_view" />
- 界面是设置播放器相关属性
val player = ExoPlayer.Builder(this).build()
playerView.player = player
player.playWhenReady = true
player.setMediaItem(MediaItem.fromUri("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"))
player.prepare()
总结
至此,就完成了ExoPlayer 2.18.2 基本使用,非常简单明了。如果我的文章有帮助到你,麻烦一键四连,点赞收藏关注转发,Peace guys