Jump to content

HTML5 video audio attribute question


BooKwiznak

Recommended Posts

I wanted to mute the audio in the video and was going through the HTML5 video tutorial section which covered the audio attribute section here:http://www.w3schools.com/html5/tryit.asp?f...ml5_video_audioThe code is:

<!DOCTYPE HTML><html><body><video controls="controls" audio="muted">  <source src="movie.ogg" type="video/ogg" />  <source src="movie.mp4" type="video/mp4" />  <source src="movie.webm" type="video/webm" />Your browser does not support the video tag.</video> </body></html>

When I press play, I still hear the audio. I've tried putting in audio="muted" on another example and I'm having the same issue.

Link to comment
Share on other sites

  • 4 months later...

Hi Mate I am trying to add a youtube video(an exact link copied off youtube website) to this document, my safari/chrome is not returning anything out of the code can u pls give a hand on this. <!doctype.html><html><head><title>my first youtube video</title></head><body><object height="200" width="300"/><param name="movie" value="http://www.youtube.com/watch?v=5P6UU6m3cqk"></param><embed height="200" width="300" src="http://www.youtube.com/watch?v=5P6UU6m3cqk"></body></html> and may i please know how to add an audio or a video file through my local computer. your help is appreciated on this. regards

Link to comment
Share on other sites

This code wasn't copied directly from youtube, you've made a lot of modifications. First of all, the object tags should surround all the rest of the tags. The URL isn't that of the video page, it should be the link to the flash document itself ( http://www.youtube.com/embed/5P6UU6m3cqk )

<object height="200" width="300">   <param name="movie" value="http://www.youtube.com/embed/5P6UU6m3cqk"></param>  <embed height="200" width="300" src="http://www.youtube.com/embed/5P6UU6m3cqk"></object>

Currently, youtube has finally decided to drop the <embed> tag, which is not valid HTML. They're using an iframe instead. You could do this instead:

<iframe width="300" height="200" src="http://www.youtube.com/embed/5P6UU6m3cqk" frameborder="0" allowfullscreen></iframe>

Link to comment
Share on other sites

You'll have to ask your web host about that. It can be done through an online file manager or through an FTP client. How do you currently put pages on your site?

Link to comment
Share on other sites

OK, if it's on your computer, just put the audio file in a folder and point to the folder from the <audio> element. To put your pages on the internet, you have to find a web host. Look on Google for web hosts. Some are free, some aren't. The free ones usually have a lot of drawbacks.

Link to comment
Share on other sites

Hi Duotone thnks 4 the reply. i hv created a folder and named it "root" and have dropped an audio file into the root folderand have tried to play audio through the following:- <audio controls="controls" height="50px" width="25px"><source src="song.mp3" type="audio/mp3"/><source src="song.wav" type="audio/wav"/></audio> and it doesnot play the audio which was saved under my root folder, same case with video as well. cheersDeepak.

Link to comment
Share on other sites

where is this HTML file relative to the audio file? Are they both in this same root folder? If the root folder is in the same folder as the HTML file, then you need to point to audio file as such

<source src="root/song.mp3" type="audio/mp3"/>

Link to comment
Share on other sites

Hi Scientist i have created a root folder and placed song.mp3 file into it, and have placed the html file with the following and have put it into the root folder, but it doesn't play the file <audio controls="controls" height="40px" width="50px"><source src="root/song.mp3" type="audio/mp3"/><source src="root/song.wav" type="audio/wav"/></audio> pls help on this.. thnk you

Link to comment
Share on other sites

you need to understand how file paths and system directories work. If the HTML AND the audio file are in the SAME folder, then the path to the audio file is just the filename. It wasn't clear where each file was. So if they are both in the SAME root folder, then the path to the audio file shouldn't have anything before it.

<source src="song.mp3" type="audio/mp3"/>

before, since you had the HTML in a folder, and THEN a root folder with the audio file in it, that's why you needed root before it in the src. You have to think like the computer, you need to tell it where to look, relative to the file that is making the request for the asset.

Link to comment
Share on other sites

what code are you using then? How about in one post, show the exact code you are using AND tell us the folder structure. It's getting too confusing cause it seems like you keep changing both things instead of making one match the other.

Link to comment
Share on other sites

Hi Scientist I have a folder called root and i have saved a file named song.mp3 in the same folder.jsut for your clarity the path to the folder was /Users/deepakshowri/Desktop/HTML/root/song.mp3 and then i tried the following code to play the song:- <audio controls="controls" height="50px" width="25px"><source src="root/song.mp3" type="audio/mp3"/><source src="root/song.wav" type="audio/wav"/><source src="root/song.ogg" type="audio/ogg"/></audio>

Link to comment
Share on other sites

ok but what about the HTML file. Using that path you gave us, which folder is the HTML file in that has the audio tags in it? And you have made sure your browser supports the audio tag, yes?

Link to comment
Share on other sites

Hi I hv tried without the directory and just the file name..it still shows me the player but it doesnot play the song thnks
you're not following us very well. I highly encourage you to read on file structures and how relative paths work in order for you understand how documents relate to themselves on the web. let me try and explain it one more time. The src is relative to the HTML document requesting the file. So you are telling it to look in root. This means that the HTML file must be one level up. OR, you remove the root, and have all three files in the same folder. However, it is preferable to organize your documents to keep things organized. So in staying with your root example, let's try this one more time. you have a folder
/Users/deepakshowri/Desktop/HTML

this is the obvious location for your html file. so leave it as it

<audio controls="controls" height="50px" width="25px"><source src="root/song.mp3" type="audio/mp3"/><source src="root/song.wav" type="audio/wav"/><source src="root/song.ogg" type="audio/ogg"/></audio>

now, you are telling the HTML file to look in a folder called root WITHIN the folder that the html file is in, in order to find the audio files. So, using the root folder

/Users/deepakshowri/Desktop/HTML/root

make sure all your audio files are in there. so at the end of it all you should have an HTML folder with an html file in it, and a root folder. Inside the root folder are your audio files.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...