vmeyer
vmeyer

Reputation: 2038

AVAggregateAssetDownloadTask seems to load m3u8 file twice

I am using AssetPersistenceManager from this Apple Sample : Using AVFoundation to play and persist http live streams I create an AVURLAsset with a playlist master url, then call downloadStream(for:) with this asset, and the AVAggregateAssetDownloadTask complete download successfully !

It saves a folder named 286943_chapter_01_C955A55455AC0C4E.movpkg which contains the downloaded segments, my .m3u8 file and a StreamInfoBoot.xml file. The StreamInfoBook.xml file contains references between local segment (or .frag) file and m3u8 segment URL.

However, those urls are signed and generated by Cloudfront. And some times, some URLs inside the .m3u8 file doesn't match URLs in StreamInfoBook.xml because of Expires parameter of cloudfrount.

So I think maybe AVAggregateAssetDownloadTask is calling the .m3u8 file twice : Once to save the .m3u8 and once to download segments and write StreamInfoBook.xml.

Does anyone already faced this issue ? What could I do to check if my Asset is playable offline or not ? Do you have any suggestion ?

Here is an exemple of not matching segment URLs

In .m3u8 downloaded file :

https: //ezvoiznbov32f.cloudfront.net/file/265579/audio/chapter_08_10.mp3?Expires=1576159816&Signature=vfAYZ8ivP7yKeiranpba3R24gTSxexX4Nb1VjbDrR917pyFQqi2DMMMf8gi3LcueKXxv0FITprXzLXV62Py0Ph4nMxp8ixf5qG5sYnW1JcO74BxNfJE~DEurN~yQgczNBOK4b~bEXrDDZId1AweYJrgjZtjSoyUwAGXf~LA_&Key-Pair-Id=APKAAFEFNOSQQ34Q

In StreamInfoBook.xml file :

https: //ezvoiznbov32f.cloudfront.net/file/265579/audio/chapter_08_10.mp3?Expires=1576159817&Signature=PZ~tqOeIa3Vm26qKTFYU1LCGfvsWNpkUDMi3eFr~EhyRTLj66CDInSwfpoorYjl4Kl4B9eQ1W8ZzTlIMDGvs36wJ235JOszeov23IuIOzAJTlNw7zQYEd4Y1tq~nyZinpFoyDRGk0CelKOhH91Itb3rpQUeMN6lDhO-cq1X1OM_&Key-Pair-Id=APKAAFEFNOSQQ34Q

I'm testing with iOS 13.2

Upvotes: 0

Views: 643

Answers (1)

vmeyer
vmeyer

Reputation: 2038

Well, answering myself :

After a very long time trying to make AVAggregateAssetDownloadTask works in background while the application is killed by the system, I finally switched to AVAssetDownloadTask.

Now everything is working perfectly ! It's like magic !

The difference between aggregate and normal tasks is in media selections. But I don't need it for now....

Upvotes: 1

Related Questions