HTTP Streamin Server works on iPhone, fails on iPad & Safari
-
12-05-2021 - |
题
I am trying to figure out HTTP Streaming Server. I have a test playlist working on Apache22, using mp3 audio files:
This playlist works on my iPhone 4s, but not my iPad, even though it's running the same version of iOS 5, or Safari on my iMac running Lion.
For the iPad, the Apache log shows the playlist getting fetched, but nothing else:
75.127.142.66 - - [30/Dec/2011:13:24:19 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 304 - "-" "AppleCoreMedia/1.0.0.9A405 (iPad; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:24:20 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 206 126 "-" "AppleCoreMedia/1.0.0.9A405 (iPad; U; CPU OS 5_0_1 like Mac OS X; en_us)"
With the iPhone, the playlist is fetched and then the audio files, as you would expect:
75.127.142.66 - - [30/Dec/2011:13:26:31 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 206 2 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:31 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 206 126 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:35 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 304 - "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:35 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 206 126 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:35 -0500] "GET /mp3/playlist.m3u8 HTTP/1.1" 200 126 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:35 -0500] "GET /mp3/1.mp3 HTTP/1.1" 200 366464 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:36 -0500] "GET /mp3/2.mp3 HTTP/1.1" 200 375865 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
75.127.142.66 - - [30/Dec/2011:13:26:36 -0500] "GET /mp3/3.mp3 HTTP/1.1" 200 316303 "-" "AppleCoreMedia/1.0.0.9A405 (iPhone; U; CPU OS 5_0_1 like Mac OS X; en_us)"
For Safari, the playlist and audio files are fetched, the same as iPhone, but nothing is displayed on web page, and no sound is played.
Here's the playlist:
#EXTM3U
#EXT-X-TARGETDURATION:44
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:15,
1.mp3
#EXTINF:16,
2.mp3
#EXTINF:13,
3.mp3
#EXT-X-ENDLIST
Pretty simple... hard to see where I might have gone wrong there, but obviously I have.
I know this is a pretty esoteric subject, but if anyone has an idea, I'd love to hear it.
Thanks
解决方案
Okay, I figured it out. It wasn't in the playlist file or audio files, but in the index file, which I figured was so simple it wasn't worth listing.
The problem was in the video tag. I made the mistake of using an example from some web tutorial, which the tag set up as so:
<video src="./playlist.m3u8" height="300" width="400" ></video>
This didn't work on iPad or Safari. Changing it to this made it work on iPad but not Safari:
<video src="playlist.m3u8" height="300" width="400" ></video>
Those URLs are equivalent, as far as I know, but...
Finally, changing it to this made it work on all platforms:
<video src="playlist.m3u8" width="320" height="40" controls="controls" autoplay="autoplay" >Your browser does not support the video tag</video>
Now I need to get the m4a files playing...