0
votes

I want to download HLS stream file in background.

I first download the m3u8-file and parse it to get many urls (about 30 ~ 200). Then I create a background session. Last, for every url, I create a NSURLSeessionDownloadTask, I create next task and download after the former one finished.

It works well when the app is in foreground. But in background, it stoped and not create new task after the current one finished.

So, How can I download the urls one by one in background? (I don't think play music in background to keep app active is a good idea)

1
Do you have appropriate background modes specified in your app's Info.plist file? developer.apple.com/library/content/documentation/iPhone/…dgatwood
Surely,I use the mode "App downloads content from the network"kunjinkao
Assuming you're actually playing the HLS stream, you'll probably want "audio" mode. That said, I doubt this is the problem. I'm assuming this isn't happening in an extension or anything (with a separate plist)....dgatwood

1 Answers

0
votes

I tried to create all of the tasks once the download began, and it seems to work.