本文介绍了在iOS应用中下载带有.m3u8网址的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ios应用程序文档目录中下载带有.m3u8 url的视频.当我使用.m3u8网址下载视频时,我收到包含以下数据的文本文件:

How to download video with .m3u8 url in ios app document directory. When i download the video with .m3u8 url I receive the text file containing following data :

EXT-X-VERSION:3

EXT-X-VERSION:3

EXT-X-STREAM-INF:PROGRAM-ID = 1,BANDWIDTH = 1057090,CODECS ="avc1.4d001f,mp4a.40.2",RESOLUTION = 854x480 14527590795694Super-Cool-Stylesstream_80.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1057090,CODECS="avc1.4d001f,mp4a.40.2",RESOLUTION=854x480 14527590795694Super-Cool-Stylesstream_80.m3u8

EXT-X-STREAM-INF:PROGRAM-ID = 1,BANDWIDTH = 1902362,CODECS ="avc1.4d001f,mp4a.40.2",RESOLUTION = 1280x720 14527590795694超级酷的样式stream_81.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1902362,CODECS="avc1.4d001f,mp4a.40.2",RESOLUTION=1280x720 14527590795694Super-Cool-Stylesstream_81.m3u8

EXT-X-STREAM-INF:PROGRAM-ID = 1,BANDWIDTH = 455156,CODECS ="avc1.4d0015,mp4a.40.2",RESOLUTION = 428x240 14527590795694超级酷的样式stream_82.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=455156,CODECS="avc1.4d0015,mp4a.40.2",RESOLUTION=428x240 14527590795694Super-Cool-Stylesstream_82.m3u8

EXT-X-STREAM-INF:PROGRAM-ID = 1,BANDWIDTH = 188580,CODECS ="avc1.4d00c,mp4a.40.2",RESOLUTION = 256x144 14527590795694超级酷的样式stream_83.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=188580,CODECS="avc1.4d00c,mp4a.40.2",RESOLUTION=256x144 14527590795694Super-Cool-Stylesstream_83.m3u8

EXT-X-STREAM-INF:PROGRAM-ID = 1,BANDWIDTH = 144773,CODECS ="avc1.4d00c,mp4a.40.2",RESOLUTION = 256x144 14527590795694超级酷的样式stream_84.m3u8

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=144773,CODECS="avc1.4d00c,mp4a.40.2",RESOLUTION=256x144 14527590795694Super-Cool-Stylesstream_84.m3u8

我不知道如何进一步下载实际视频,以便它可以在离线模式下播放.请提出建议.

I have no idea how to proceed further to download actual video so that it can pe played in offline mode. Please suggest.

推荐答案

此线程来寻找解决方案的任何人:

For anyone who comes by this thread looking for a solution:

从iOS 10开始,可以使用AVAssetDownloadURLSession来实现.

Since iOS 10, this can be achieved using AVAssetDownloadURLSession.

这是Apple提供的有关下载HLS资产以供离线使用的完整指南:

Here's a complete guide from Apple on downloading HLS assets for offline use:

使用HTTP实时流传输

这篇关于在iOS应用中下载带有.m3u8网址的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 20:43