android - How display thumbnail image in Exoplayer video?
问题描述
I want to assign a preview image of the video from a URL. After pressing Play, it should disappear and show the video. I have searched for info but I have not found anything, please if anyone has any more extensive information on the subject. Thank you!
My code:
val mPlayer: SimpleExoPlayer
val inflater = activity?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contenedor: View = inflater.inflate(R.layout.nota_exoplayer_container, null)
val playerView: PlayerView = contenedor.findViewById(R.id.exoPlayer)
playerView.useController = true
playerView.requestFocus()
val bandwidthMeter: BandwidthMeter = DefaultBandwidthMeter()
val videoTrackSelectionFactory: TrackSelection.Factory = AdaptiveTrackSelection.Factory(bandwidthMeter)
val trackSelector: TrackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
mPlayer = ExoPlayerFactory.newSimpleInstance(activity.applicationContext, trackSelector)
playerView.player = mPlayer
val fullScreenBtn = playerView.findViewById<ImageView>(R.id.exo_fullscreen_icon)
val defaultBandwidthMeter = DefaultBandwidthMeter()
val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(
activity.applicationContext,
Util.getUserAgent(activity.applicationContext, "VID"),
defaultBandwidthMeter)
val mediaSource = ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
mPlayer.prepare(mediaSource)
My layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/exoContainer"
android:orientation="vertical"
style="@style/ajustar_al_padre">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoPlayer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
解决方案
- 您的打包程序必须在您的 DASH 清单中写入 mimeType“图像”的 AdaptationSet。
- 然后,您需要创建一个自定义 DashManifestParser(),它将从 DASH 清单中获取“图像”AdaptationSet。
- 将此 ManifestParser 添加到您的 MediaSource 以提取缩略图 url 和位置
推荐阅读
- java - Amazon S3 Select 问题:不支持在字段内发生换行符
- java - 为什么我需要一个独立的存储库的片段接口?
- javascript - java: 包 netscape.javascript 不存在,尽管已将 plugin.jar 添加到类路径
- angular - Angular 7/Typescript -Sort 以特定顺序选择下拉选项
- r - 日期数据集与 R 中的时间线争吵
- python - 在python中限制用户输入
- node.js - 快速路由中的 req.on 和 req.socket.on 有什么区别?
- angular - Angular-universal MutationObserver 问题
- php - 在 PHP 中将 UTF-16LE 转换为 UTF-8 - 拉丁扩展
- javascript - 如何从无状态父级访问子类组件中的函数?