在 Android 应用程序开发中预加载或预缓冲 .mp4 视频 [英] Pre-Load or Pre-Buffer .mp4 video in android app development

查看:85
本文介绍了在 Android 应用程序开发中预加载或预缓冲 .mp4 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个在ButtonClick 上成功显示MP4 视频文件的应用程序.我想预缓冲或预加载视频的 URI(远程 url),以便在单击按钮后不会延迟视频的播放.我希望它立即点击并播放,因此在应用程序启动画面上预加载或缓冲似乎是一个合适的解决方案.唯一的问题是我不知道如何.我有大量的 Android 书籍,但几乎没有任何一本涵盖缓冲,或者只涵盖音频.

I am building an app that is successfully displaying an MP4 video file onButtonClick. I want to pre-buffer or preload the video's URI (remote url) so that it doesn't delay the playing of the video once the button is clicked. I want it to click and play right away, so pre-loading or buffering on the app launch splash screen seems like a fitting solution. Only thing is I don't know how. I have tons of Android Books, but hardly any of them cover buffering at all or they only cover audio.

谁能告诉我如何缓冲以前活动的视频?

Can anyone let me know how to buffer the video on a previous activity?

谢谢.

推荐答案

Google 发布 ExoPlayer,提供更高级别的媒体播放:http://developer.android.com/guide/topics/media/exoplayer.html

Google released ExoPlayer which provides a higher level for media playing : http://developer.android.com/guide/topics/media/exoplayer.html

它支持不同的状态,例如在后台缓冲:

It supports different state such as buffering in background :

// 1. Instantiate the player.
player = ExoPlayer.Factory.newInstance(RENDERER_COUNT);
// 2. Construct renderers.
MediaCodecVideoTrackRenderer videoRenderer = …
MediaCodecAudioTrackRenderer audioRenderer = ...
// 3. Inject the renderers through prepare.
player.prepare(videoRenderer, audioRenderer);

我在我自己的项目中使用了它,它似乎非常有效.谷歌还制作了播放器的完整演示:https://github.com/google/ExoPlayer/tree/master/demo/src/main/java/com/google/android/exoplayer/demo/full 这是更多比简单的演示更强大.

I used it in my own project and it seems pretty efficient. Also Google made a Full Demo of the player : https://github.com/google/ExoPlayer/tree/master/demo/src/main/java/com/google/android/exoplayer/demo/full which is more powerfull than simple demo.

这篇关于在 Android 应用程序开发中预加载或预缓冲 .mp4 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆