ExoPlayer无法从文件播放(ExoPlayer not playing from file)

编程入门 行业动态 更新时间:2024-10-18 08:23:31
ExoPlayer无法从文件播放(ExoPlayer not playing from file)

我有一个使用HlsRendererBuilder设置的ExoPlayer 。 到目前为止,我已经将Uri传递给服务器上的m3u8流文件。 它工作得很好。 现在我可以选择将视频下载到手机上并从存储中播放。 我已成功从给定链接下载文件,将其存储在app私人文件夹中。 请求和批准访问外部存储的所有权限。 在这种情况下,我从我下载的文件传递一个Uri。 Uri看起来像这样: file:///storage/emulated/0/video/file.mp4 。 当我开始播放时,永远不会加载文件。 我在日志中没有任何异常或错误。 任何人都可以帮我建议一种方法吗? 如果需要,我将提供代码片段,但不确定哪个部分有用。

我有ExoPlayer.Listener ,它记录了播放器状态。

当我正在流媒体时,我得到各种状态,从IDLE - > BUFFERING - > READY - > BUFFERING ......等等基于互联网连接或媒体结束ec。 当我播放存储文件时,我只获得状态IDLE,没有其他任何事情发生。 我永远得到黑屏,直到我finish()活动。

当我尝试从本地存储中播放流文件时,我确实遇到了一个FileNotFound异常,它无法找到该文件,这是流文件中列出的下一部分媒体。 我认为问题出在玩家设置中? 不确定...

I have a ExoPlayer set up with HlsRendererBuilder. So far I have been passing it an Uri to a m3u8 stream file on the server. It is working great. Now I have an option to download the video to your phone and play it from storage. I have successfully downloaded the file from the given link, stored it in the app private folder. All permissions to access external storage requested and approved. In this case I am passing an Uri from file which I have downloaded. Uri looks like this: file:///storage/emulated/0/video/file.mp4. When I start the playback the file is never loaded. I do not get any exception or error in the log. Can anyone help me to suggest an approach? I will provide snippet of codes if needed, but not sure which part would be useful.

I have ExoPlayer.Listener which logs me of the player state.

When I am streaming I get various states starting from IDLE -> BUFFERING -> READY -> BUFFERING ... so on based on the internet connection or if the media ended ec. When I am playing stored file I only get state IDLE and nothing else happens. I got black screen forever until I finish() the activity.

When I tried to play stream file from local storage I did got an FileNotFound exception that it cannot find the file, next part of media listed in the stream file. I assume the problem would be in the player setup? Not sure...

最满意答案

您需要为本地(视频/音频)文件使用不同的RendererBuilder 。

ExtractorRendererBuilder是你应该看的东西。

You need to use a different RendererBuilder for a local (video/audio) file.

ExtractorRendererBuilder is the thing you should be looking at.

更多推荐

本文发布于:2023-04-28 01:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   ExoPlayer   file   playing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!