1.11M Members

Help with redirect type thing

 
0
 

The html works fine, shows a little player, and plays just great.

<!DOCTYPE html>
<html>
<body>

<audio controls>
  <source src="NewMp3.mp3" type="audio/mpeg">
  <embed height="50" width="100" src="NewMp3.mp3">
</audio>

</body>
</html>
 
1
 

Sorry, I have to remove it my response. I think you already got it sorted out..

 
0
 

I have not got it sorted, maybe I gave the wrong impression (it's how my first was born).
This just puts a player in a page on my site and clearly shows the song name, which is the whole point of my problem.

 
0
 

ok, here we go again. I am not going to provide any link because, for some reason the mp3 I would like to be the demo for this response is misbehaving badly :).

I only tested this on IE, because that is the only one I have at the moment.

Here we go, we can provide link from any page using this syntax

    <a href="mp3streamer.php?file=pinkfloyd">Pink Floyd </a>

Ok, just to remind you that the file name is up to you. YOu can rename your mp3 like mysterysong101.mp3, it does not matter.

Here is the script..

    <?php
    ## Warning! not tested in firefox ONLY in IE. This script triggers the windows media player.

    if(isset($_GET['file']) && (!empty($_GET['file']))){
     $thisMp3 = mp3Streamer($_GET['file'],'.mp3');
    }
    else{

    //nothing 

    }

    function mp3Streamer($title,$ext){

    ## define secret directory
    $loc = 'uploads/';

    ## based on the known vars we have the actual filename, location, and extension
    $actual_file = $loc.$title.$ext;
    ## mime types possible
    $mType = "  audio/mpeg3, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg"; 
    ## we double check and make file exist
    if(file_exists($actual_file)){

    ## do as what we already know
        header('Content-type: {$mType}');
        header('Content-length: ' . filesize($actual_file));
        header('Content-Disposition: filename="'. $actual_file .'"');
        header('X-Pad: avoid browser bug');
        header('Cache-Control: no-cache');
        $mfile = readfile($actual_file);

        ## ! source src was left blank intentionally ##
        ###############################################

        $thisAudio = '<audio controls height="100" width="100">
      <source src="" type="audio/mpeg">
      <embed height="50" width="100" src="'.$mfile.'">
       </audio> ';
    die(); 
    }

    else{

    $thisAudio = 'not available';

    }

    return $thisAudio;

    }

    ?>

Good luck to you.. :)

 
0
 

Hi veedeoo, thank you for your time and effort.
Your script works fine as it is supposed to, but unfortunately is the same as
the codes above, in that if I view the page source, the title and artist are clearly visible, and it does not work in media tags either in chrome, IE or firefox.

When I started this thread, It was my hope that I could have a link "www.domain.com/fakemp3.mp3" but when navigated to of put in tags, a different song would be served.

Thank you all once again for trying, but I believe it not possible at this time and try to think of another method of acheiving my goal.

Cheers.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article