Streaming mp3 audio with AVPlayer

后端 未结 5 1278
眼角桃花
眼角桃花 2020-11-28 22:09

I\'m hearing some conflicting reports about this. What I\'m trying to do is stream an mp3 file from a URL. I\'ve done hours of research, but I cannot find any good guides on

5条回答
  •  暖寄归人
    2020-11-28 22:52

    Aaron's post about using an m3u file instead of an mp3 worked for me. I also found that AVPlayer was picky about the m3u syntax. For example, when I tried the following, I was unable to get a valid duration (it was always indefinite), and relative paths didn't work:

    #EXTM3U
    #EXTINF:71
    https://test-domain.com/90c9a240-51b3-11e9-bb69-c1300ce2348f.mp3
    

    However, after updating the m3u file to the following, both issues were resolved:

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:70
    #EXT-X-MEDIA-SEQUENCE:1
    #EXT-X-PLAYLIST-TYPE:VOD
    #EXTINF:70.000,
    8577d650-51b3-11e9-8e69-4f2b085e94aa.mp3
    #EXT-X-ENDLIST
    

提交回复
热议问题