How can I add control to my embed audio? - html

I added some music to my website that starts when you load it. I also want to give the option to pause/unpause it. What must I do to add control?
<embed controls autostart="true" height="0" loop="true" src="URL://music-file" width="0" />

Use HTML5
A simple way to achieve this is, to use HTML5 and it's audio tag.
<audio controls autoplay>
<source src="MP3 PATH" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

Related

How to add an MP3 file as a background on a HTML page

I'm trying to add in some music to a landing page on my website, the file is called "LandingPageMusic.mp3" and it is in a separate folder called "Music". When I insert the following code into the body of the page, no music plays - I am using Google Chrome FYI.
<embed src="LandingPageMusic.mp3" autostart="true" loop="true">
If you use HTML5, you can use <audio> now:
<audio autoplay loop style="display:none;">
<source src="LandingPageMusic.mp3" type="audio/mp3">
</audio>
This should give you an audio player that autoplays, and style will hide the player.
try that :
<audio autostart loop>
<source src = "LandingPageMusic.mp3">
</audio>

How to insert a video into HTML?

<html><body><video src="C:\Users\vps\Desktop\v.mp4" width="50%" controls>
<p>If you are reading this, it is because your browser does not support the 'video' element. Try using the 'object' element listed further down the page.</p></video><p>If you can see the video controls but the video doesn't play when you click the "Play" button, your browser might not support this file type (i.e. <code>Ogg</code>). In this case, try the same code, but with a different file format.</p>enter code here</video></body></html>
Hope this helps:
<video width="300" height="400" id="vid" controls>
<source src="https://developer.apple.com//live-photos/assets/boy.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
Refer the below link, This will explain about adding video file.
https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_video

media files do not play with hidden property set to true of embed tag

Here is my embed tag
<embed src="http://localhost:8084/MIS/js/status_no.mp3" hidden="true" autostart="true" loop="false" class="playSound">
When I remove hidden property, sound gets played but when i set hidden property to true, sound does not play. I do not want to show the player to the user.
<audio>
<source src="../js/Alarm_Buzzer.ogg" type="audio/ogg"></source>
</audio>
This worked for me in both chrome as well as firefox. Firefox did not support mp3 files but chrome did.
You can try to hide it with CSS:
.playSound { display: none; }
Also I'd like to suggest using the audio tag, it's meant for this type of content.
I would recommend converting your code into something like this and this works on all browsers
<audio autoplay>
<source src="http://localhost:8084/MIS/js/status_no.ogg" type="audio/ogg">
<source src="http://localhost:8084/MIS/js/status_no.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
This code will work on all browsers, it will also be hidden and will start automatically.
If you add controls="controls" in audio tag then the audio player will be visible to the user.
so for your case just don't add controls.
<audio src="http://a.tumblr.com/tumblr_mfezft44rf1rge0duo1.mp3" autoplay="autoplay" loop="false" class="playSound"></audio>
Hope this helps!
<embed src="https://www.youtube.com/v/watch?v=KA_8oaTpxac&autoplay=1&loop=1" type="application/x-shockwave-flash"
wmode="transparent" height="1" width="1">
I think this works but note : Very important
if video on you tube : the line is :
https://www.youtube.com/watch?v=vid number
but you have to write it in this form in the code
https://www.youtube.com/v/watch?v=vid id
and will work fine

I want to add inline video and sound but html tags are not working

I am trying to add a inline sound in a web page but when i add and open the web page it plays automatically..I used <object>,<embed> everything but autostart="false" and autostart="0" is not working in IE,Mozilla and Chrome.I also tried to add inline video but it is also not playing.Please help me.I really need a help.
You should use the HTML5 way of doing it. The current major browsers can do fine with that. The big advantage: No need for extra plugins and bogous <object> and <embed> tags.
Example for embedding audio:
<audio controls="controls">
<source src="sound-ogg.ogg" type="audio/ogg" />
<source src="sound-mp3.mp3" type="audio/mpeg" />
</audio>
See w3schools HTML5 audio on this topic for better examples and explanation.
Video is as easy:
<video width="800" height="600" controls="controls">
<source src="video-ogg.ogg" type="video/ogg" />
<source src="video-mpeg.mpg" type="video/mp4" />
<source src="video-webm.webm" type="video/webm" />
</video>
Again, w3schools has a deeper explanation with examples.
To convert audio and video to the required formats, I use Handbrake.
For an multi-browser support (HTML5 and no HTML5) take a look at video.js. In my humble opinion, this is the best way of including video content.

Play sound file in a web-page in the background

I want to play a sound file on my web-page in the back-ground(don't want Media player UI to appear), my web-site will run on Fire-Fox, i used the Embed element and set the Hidden attribute to be true <embed name="myMusic" src="Masgon.mp3" type="audio/midi"
autostart="false" Hidden="true" loop="true"></embed>
the problem is that no sound is played unless i removed the hidden attribute on this case the sound file is played and the media player UI appears but i don't want that.
<audio src="/music/good_enough.mp3">
<p>If you are reading this, it is because your browser does not support the audio element. </p>
</audio>
and if you want the controls
<audio src="/music/good_enough.mp3" controls>
<p>If you are reading this, it is because your browser does not support the audio element.</p>
</audio>
and also using embed
<embed src="/music/good_enough.mp3" width="180" height="90" loop="false" autostart="false" hidden="true" />
<audio src="/music/good_enough.mp3" autoplay>
<p>If you are reading this, it is because your browser does not support the audio element. </p>
<embed src="/music/good_enough.mp3" width="180" height="90" hidden="true" />
</audio>
Works for me just fine.
Though this might be too late to comment but here's the working code for problems such as yours.
<div id="player">
<audio autoplay hidden>
<source src="link/to/file/file.mp3" type="audio/mpeg">
If you're reading this, audio isn't supported.
</audio>
</div>
<audio controls autoplay loop>
<source src="path/your_song.mp3" type="audio/ogg">
<embed src="path/your_song.mp3" autostart="true" loop="true" hidden="true">
</audio>
[ps. replace the "path/your_song.mp3" with the folder and the song title eg. "music/samplemusic.mp3" or "media/bgmusic.mp3" etc.
With me the problem was solved by removing the type attribute:
<embed name="myMusic" loop="true" hidden="true" src="Music.mp3"></embed>
Cerntainly not the cleanest way.
If you're using HTML5:
MP3 isn't supported by Firefox. Wav and Ogg are though.
Here you can find an overview of which browser support which type of audio:
http://www.w3schools.com/html/html5_audio.asp
If you don't want to show controls then try this code
<audio autoplay>
<source src="song.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
if you want it just normal:
<audio src="sus.mp3">
<script>alert("Your browser doesn't support the Audio tag!")</script>
</audio>`
if you want it to automatically start on load: (Not supported by chrome)
<audio src="sus.mp3" autostart="true">
<script>alert("Your browser doesn't support the Audio tag!")</script>
</audio>
if you want the controls
<audio src="sus.mp3" autostart="true" controls>
<script>alert("Your browser doesn't support the Audio tag!")</script>
</audio>