Generic filenames to play audio? - html5-audio

Hi and thanks so much for your help.
I am adding about 600 .mp3 audio files into individual HTML files. I am wondering if there is any code that I can use to look for and play a file extension (.mp3) and not the full file name.
Is it possible for HTML to overlook a file name and just look for the .mp3 extension? If the file name is example.mp3, is there code that will ignore the example and just look for .mp3. This would save me a lot of renaming and recoding.
Here is my current code:
<audio id="Audio">
<source src="filename.mp3" type="audio/mp3" />
</audio>
Thanks in advance for any help at all.
Nate

Related

Please explain why my mp3 file won't play

I'm watching a Youtube video to learn HTML and CSS.
https://www.youtube.com/watch?v=cyuzt1Dp8X8&t=5566s
I downloaded an mp3 file to my computer, but when I run my code, the audio file doesn't play. In my HTML code, I used the name of the audio file rather than the path. I know the name of the mp3 file is correct. However, by using the path rather than the file name, I have been able to play the audio in my browser. Again, the first code will NOT play the audio file, but the second code will play the audio file.
<audio controls>
<source src="CouldItBeKP.mp3" />
</audio>
<audio controls>
<source src="C:\Users\james\Downloads\CouldItBeKP.mp3" />
</audio>
Also, the author of the Youtube video believes the location of the audio file matters. For example, the audio file won't play if I move the mp3 file from Desktop to Downloads or vice versa. The code is below.
<audio controls>
<source src="CouldItBeKP.mp3" />
</audio>
Please help! Thanks.
When you do not specify the full path, most browsers will assume that the file is in the same folder. So if your code was in ~\Documents, but the audio was in ~\Downloads, it would not play. If they were both in ~\Documents, it would play.
You need the path to be correct, without the path it greys out. Put it in your main directory and try ./CouldItBeKP.mp3
it seems like your audio files are on the downloads folder, but I'm not sure where your code is.
I would suggest you move your audio files and your codes to the same directory.
For example, if my HTML file is in
C:\Users\james\project
My music files also should be also in C:\Users\james\project or somewhere near this folder. Eg: C:\Users\james\project\music
Now, let's assume, my music files are inside C:\Users\james\project\music while my HTML file is in C:\Users\james\project
So, my code for playing the music would be like this.
<audio controls>
<source src="music/CouldItBeKP.mp3" />
</audio>
Or
<audio controls>
<source src="./music/CouldItBeKP.mp3" />
</audio>
./ means to start from the current folder. In our case, which is C:\Users\james\project
Then your second code will also play the audio.

how should we link videos and audios on our html file?

<video width="500" height="500" controls="contrlos">
<source src="hope.mp4" type="video/mp4">
</video>
this is the code I tried on vscode, the video file is stored in my drive c, but I don't know why when I run it, it doesn't work, and I cannot play the video. by the way I open it in Chrome. and when I google a video and copy the link address in src="" the same problem repeat. does the audio and video files we want to put in html need to be stored in a special place in my computer?? plz help me! I'm beginner.
There are 2 solutions of this problem:
Keep the video file in same folder where you have stored your html file or
Wrrite the full path of the video file where you have stored.

Playing live streaming .wav file in HTML

I have a .wav file that is being continuously appended to. Is it possible to play this file using the HTML <audio> element? Here is my current approach:
<audio controls="controls" autoplay="autoplay" preload>
<source src="stream.wav/" type="audio/wav">
</audio>
If I refresh the page, it reflects the new audio available in the file, but it does not render as a streaming player. It seems like it should be playing in "live" mode according to this question.
I would also be open to using some kind of framework or JavaScript to accomplish this if that would be best practice, but I haven't found anything yet.
Files cant end in /
src="stream.wav/"
Should be src="stream.wav"
In order to stream live audio and video, you will need to run specific streaming software on your server or use third-party services.
https://developer.mozilla.org/en-US/docs/Web/Guide/Audio_and_video_delivery/Live_streaming_web_audio_and_video#Server-side_Streaming_Technologies
That section of that page lists a few popular options for doing this.

Insert audio file in web page

I want to insert an audio file in my web page. I have the .mp3, but not the .ogg, so my audio won't play. What can I do to insert that file?
I have the following code:
<audio controls autoplay>
<source src="Viva-la-vida.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Please correct me if I said something wrong. Thank you in advance!
The code you mentioned is working great with .mp3 file. You can do two things.
Check the path you specified in the src attribute for the .mp3 file.
Run your .html file in different browsers.

Playing a pls file using HTML5 audio

I want to play a .pls file which is an radio file. When I click over this file it plays video in my iIunes (I am using mac). I want to play this pls file in browser especially in Safari as I want to play it in iPhone.
My code:
<audio src="radioveronica.pls" controls="controls">
Your browser does not support the audio element.
</audio>
Following is content of my pls file:
[playlist]
File1=http://5713.live.streamtheworld.com:80/VERONICAAACCMP3
Title1=Radio Veronica
Length1=-1
File2=http://5713.live.streamtheworld.com:3690/VERONICAAACCMP3
Title2=Radio Veronica
Length2=-1
File3=http://5713.live.streamtheworld.com:443/VERONICAAACCMP3
Title3=Radio Veronica
Length3=-1
File4=http://5723.live.streamtheworld.com:80/VERONICAAACCMP3
Title4=Radio Veronica
Length4=-1
File5=http://5723.live.streamtheworld.com:3690/VERONICAAACCMP3
Title5=Radio Veronica
Length5=-1
File6=http://5723.live.streamtheworld.com:443/VERONICAAACCMP3
Title6=Radio Veronica
Length6=-1
NumberOfEntries=6
Version=2
for shoutcast servers is without stream.nsv(most servers)
for icecast is like you said , for virtual dj is same as shoutcast , example:
<html>
<head><title> Listen To Ma' Radio</title></head>
<body>
<audio controls="controls" src="http://50.22.217.113:13679/;&type=mp3"></audio>
</body>
</html>
and you can implent another functions , as it it basic html you can even implent in php , enjoy
The pls file is actually just a text file that contains a link or links to audio streams or other source files. There is no audio data in the file that can be played directly.
There are only four formats supported by the audio tag (and not in all browsers):
Ogg Vorbis
MP3
WAV
(Safari actually also supports another format which need not be named)
Yes, you can stream thru HTML5 audio tag:
<audio controls="controls" src="http://IP:port/;stream.nsv&type=mp3"></audio>
Fantastic