ExoPlayer 2.18.2 基本使用(一)

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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容