How to play .m3u8 or .ts file in iOS?

人走茶凉 提交于 2019-12-10 19:05:51

问题


I have create one iOS application in xCode 4.5.1.

The main purpose of this applciation is the playing .m3u8 video file.

I have add one .m3u8 file with all segment(.ts) in our local resource bundle. So, how to play this file in iPhone locally using MPMoviePlayerController or UIWebView?

And, Can we modify or not this file after the download from the server?

If possible then how to do it?

pls tell me, any one known...


回答1:


You will only be able to play the HLS content if it's being served over HTTP. So you should run a simple http server in one thread, and then pass the local URL to MPMoviePlayerController. The URL will look like http://localhost:8080/file.m3u8 and the video player will read the stream from the http server you have running in another thread.

Here is a question about running a webserver on iOS that might help you along: iPhone HTTP Server




回答2:


You can host the .m3u8 file on local server e.g GCDWebServer. Just create its instance and pass the path of .m3u8 file in that server. Then use the server generated local host path and pass it to your player It will automatically fetch the key and .ts file as per the content written in .m3u8 file.



来源:https://stackoverflow.com/questions/15427360/how-to-play-m3u8-or-ts-file-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!