예제 #1
0
 public function testParse()
 {
     $url = "http://127.0.0.1:8000/test";
     $parsed = parseMp3Stream($url);
     $this->assertEquals($parsed["protocol"], "http");
     $this->assertEquals($parsed["site"], "127.0.0.1");
     $this->assertEquals($parsed["port"], "8000");
     $this->assertEquals($parsed["loc"], "/test");
     $url = "http://jamusj.github.com";
     $parsed = parseMp3Stream($url);
     $this->assertEquals($parsed["protocol"], "http");
     $this->assertEquals($parsed["site"], "jamusj.github.com");
     $this->assertEquals($parsed["port"], "80");
     $this->assertEquals($parsed["loc"], "/");
     $url = "http://jamusj.github.com/test";
     $parsed = parseMp3Stream($url);
     $this->assertEquals($parsed["protocol"], "http");
     $this->assertEquals($parsed["site"], "jamusj.github.com");
     $this->assertEquals($parsed["port"], "80");
     $this->assertEquals($parsed["loc"], "/test");
 }
예제 #2
0
파일: stream.php 프로젝트: jamusj/iphone
     without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     POSSIBILITY OF SUCH DAMAGE.
*/
require_once 'streamlib.php';
$url = resolveMp3Stream($_GET["url"]);
$parsed_url = parseMp3Stream($url);
header('Content-Type: audio/mpeg');
if (strcmp($_SERVER["HTTP_RANGE"], "bytes=0-1") == 0) {
    header("HTTP/1.1 206 Partial Content");
    header('Accept-Ranges: bytes');
    header('Content-Range: bytes 0-1/4000000000');
    echo chr(255);
    echo chr(0xfb);
    exit;
} else {
    if (isset($_SERVER["HTTP_RANGE"])) {
        header("HTTP/1.1 206 Partial Content");
        header('Content-Length: 4000000000');
        header('Content-Range: bytes 0-3999999999/4000000000');
        header('Accept-Ranges: bytes');
    } else {