Hide stream url in HTML5 audio tag

Discussion in 'PHP' started by Nesooo, Apr 6, 2012.

  1. #1
    I use this code below to hide stream url of songs for my wordpress site … this mean instead of: mysite.com/audio.mp3 url is mysite.com/streem.php?id=53502

    I have tested it with default html 5 player and it works on chrome and IE, but this is not working with this player: http://goo.gl/HziDr

    Can anybody tell me is my code ok?

    Code of streem.php is:

    <?php
    require('./wp-config.php');  
    $wp->init();  
    $wp->parse_request();  
    $wp->query_posts();  
    $wp->register_globals(); 
    $attachmentID = $_GET['id'];
    $attachment = get_attached_file( $attachmentID , false );
    header("Content-Transfer-Encoding: binary"); 
    header('Content-Length: '. (string)filesize($attachment)); // provide file size
    header('Content-type: audio/mpeg');
    header('Cache-Control: no-cache');
    readfile($attachment);
    exit;
    ?>
    PHP:
     
    Nesooo, Apr 6, 2012 IP
  2. snowelephant

    snowelephant Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #2
    I can't test that player, since I don't have a copy of their code, and probably most people here don't. The best way for you to test this is to run an HTTP debugger on your development machine. Fiddler is a very good option on Windows. This will allow you to see the HTTP responses, you can then copy that into a diff tool such as Winmerge. In the diff tool you can see the difference between your output and a working one (e.g. the one on codecanyon)
     
    snowelephant, Apr 6, 2012 IP
  3. Nesooo

    Nesooo Well-Known Member

    Messages:
    186
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Nesooo, Apr 6, 2012 IP