Streaming mp3 file through php

前端 未结 3 1466
太阳男子
太阳男子 2020-12-31 20:39

Here is my php code to stream mp3 file through php

set_time_limit(0);
$dirPath = \"path_of_the_directory\";
$songCode = $_REQUEST[\'c\'];
$filePath = $dirPat         


        
3条回答
  •  忘掉有多难
    2020-12-31 21:06

    I know this is old, but we just bumped into the same kind of problem with iOS.

    Basically, it seems that if your app uses the native player to read the file, you NEED to implement Accept-Ranges and 206 Partial Content for your file to be read.

    In our case, what was happening was that the file was 4 minutes long in total. The app would play for around 1min 50 seconds and then would loop back to the start. It would not detect the total length of the file.
    Even though we had set up Accept-Ranges to none, iOS was ignoring it and was still asking for parts of the file. Since we were returning the whole thing, it was "looping" back to the beginning on the next "range" read.

    For the implementation of Partial Content, we used https://mobiforge.com/design-development/content-delivery-mobile-devices, Appendix A: Streaming for Apple iPhone by Thomas Thomassen

    I hope this helps someone

提交回复
热议问题