Posts o[html] play ogg / mp3
Post
Cancel

o[html] play ogg / mp3

reference http://www.w3schools.com/tags/ref_av_dom.asp

solution 1 - HTML5 (always use ogg format)

1
<audio autoplay="true" src="http://www.vorbis.com/music/Epoq-Lepidoptera.ogg">

manipulate through JS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	$(function()		{

			$('#btn_Play').on('click', function(e)				{
					console.log("123");
					var newSongEl = document.getElementById("muzik");
					//newSongEl.currentTime = 0;
					newSongEl.play();				});

			$('#btn_Pause').on('click', function(e)				{
					console.log("456");
					var newSongEl = document.getElementById("muzik");
					newSongEl.pause();				});
		})

	<button id="btn_Play">		Play	</button>
	<button id="btn_Pause">		Pause	</button>
	<audio id="muzik" src="chime.ogg"></audio>

solution 2 - jQuery HTML5 Audio http://jplayer.org/

solution 3 - swf http://code.google.com/p/mp3player/ OR http://flash-mp3-player.net/ OR http://github.com/neolao/mp3-player

snippet - hidden and autoplay :

1
2
3
4
<object type="application/x-shockwave-flash" data="player_mp3_js.swf" width="1" height="1">
<param name="movie" value="player_mp3_js.swf">
<param name="FlashVars" value="mp3=test.mp3&autoplay=1">
</object>

solution 4- SoundManager 2 makes it easier to play audio using JavaScript. http://www.schillmania.com/projects/soundmanager2/</audio>

origin - http://www.pipiscrew.com/?p=1716 html-play-mp3

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags