JavaScript How to stream audio files without giving absolute path stream audio files,stream audio files php,stream audio files

Is there anyway to stream an audio file without giving complete path of the file.

For example whenever we tried to play mp3 file with HTML5 Audio tag or With javascript, then i have to supply complete path of mp3 file something like this

<audio controls>
  <source src="http://example.com/file/hello_name.mp3" type="audio/mpeg">
</audio>

So, i think can we supply an id of the mp3 file instead of complete path of the file which should be something like this:

<audio controls>
  <source src="http://example.com/stream.php?file_id=111" type="audio/mpeg">
</audio>
Answer:1

Your stream.php file will look like this:

<?php
    // Say you hava a table "file_paths" with two columns file_id and file_path
    $sql = $pdo->prepare("SELECT FROM file_paths WHERE file_id = ?");
    $sql->bindValue(1, $_GET['file_id'], PDO::PARAM_INT);
    $sql->execute();
    $fetch = $sql->fetchObject();

    // retrieve file path using its id
    $path = $fetch->file_path;
    header("Location: " . $path);
?>

And then on target page, add the player by passing file_id to stream.php like this:

<audio controls>
  <source src="stream.php?file_id=123" type="audio/mpeg">
</audio>
Answer:2

I have two .env files like dev.env and staging.env. I am using typeorm as my database ORM. I would like to know how to let typeorm read either of the config file whenever I run the application. Error: ...

I have two .env files like dev.env and staging.env. I am using typeorm as my database ORM. I would like to know how to let typeorm read either of the config file whenever I run the application. Error: ...

  1. nestjs typeorm configuration
  2. nestjs typeorm config

I have a reference to a component <Gmap ref="mapRef"> In mounted I am doing this, just to see the objects are available mounted(){ let self = this console.log(self.$refs) // Shows the ...

I have a reference to a component <Gmap ref="mapRef"> In mounted I am doing this, just to see the objects are available mounted(){ let self = this console.log(self.$refs) // Shows the ...

I developed in and published a game to the Play Store made with the Phaser gaming engine and Cordova. When this game is good enough, I would like to publish it to the App Store, but I've read that ...

I developed in and published a game to the Play Store made with the Phaser gaming engine and Cordova. When this game is good enough, I would like to publish it to the App Store, but I've read that ...

  1. will apple approve me for financing
  2. does apple approve apps over the weekend
  3. does apple approve webview apps
  4. does apple approve apps on weekends
  5. does apple approve of malwarebytes
  6. will apple card approved me

Django 1.8 and python 2.7. I am trying to update the location of a marker using jQuery and Ajax. My json object has only one array: [{"latitud": "55.75222", "ciudad": "Moscu", "longitud": "37.61556"...

Django 1.8 and python 2.7. I am trying to update the location of a marker using jQuery and Ajax. My json object has only one array: [{"latitud": "55.75222", "ciudad": "Moscu", "longitud": "37.61556"...

  1. update markers on google maps
  2. after effects update markers from source