Use jplayer to play a "background" sound

309 views
Skip to first unread message

Biagio

unread,
Oct 21, 2011, 7:05:29 AM10/21/11
to jpl...@googlegroups.com
Hi
 
I'm trying to use japlayer to play a "background" sound in my webpage hiding the player.
i've tried in this way:
 
<script type="text/javascript">
$(document).ready(function(){
 $("#player").jPlayer({
  ready: function (event) {
   $(this).jPlayer("setMedia", {
    mp3:"song.mp3",
   }).jPlayer("play");
  },
  swfPath: "../js/jQuery.jPlayer.2.1.0/",
  supplied: "mp3",
  wmode: "window"
 });
$("#jplayer_inspector").jPlayerInspector({jPlayer:$("#player")});
});
 
</script>
 
and i added a div like this in the body of my html page:
 
<div id="player" class="jp-jplayer"></div>
 
It works but i would know if it's the right way to do it.
 
thanks in advance for your kind help
 
Biagio
 

Dustin Blake

unread,
Oct 21, 2011, 5:06:50 PM10/21/11
to jpl...@googlegroups.com
If its working as you intend it to, how could it not be right? :)

One thing I might add however, is to turn repeat on, unless you want the song to end and not play again on the site until its refreshed/reloaded.

Remember that unless the lack of player controls is a necessity to the experience, you should always provide your users a way to stop the music from playing, either by a pause/play button, or a volume/mute control.

Biagio

unread,
Oct 24, 2011, 5:12:43 PM10/24/11
to jPlayer: HTML5 Audio & Video for jQuery
You're right but i'm a perfectionist :)
for example....why i should need to use the inspector to play a sound
without the player controls?
I've tried it on mobile phone with android and it seems doesn't
work....i can't understand why

anyway thanks for your help

Mark Panaghiston

unread,
Oct 25, 2011, 6:53:43 PM10/25/11
to jpl...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages