Forums / Cotonti / Extensions / new jQuery module

jPlayer

booka
#23753 2010-03-25 03:10
Can anyone please tell how I can add some javascript which can be used as pluging without hacking the core?

I need to add nezt piece of code
<head>
part. Now it is fixed but I suppose to add possibility of changing some parameters with PHP.
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="js/demos.common.js"></script>
<script>

$(document).ready(function(){

   $("#jquery_jplayer").jPlayer({
		ready: function () {
			//playTrack("http://localfest/audio/morcheeba_-_world_looking_in.mp3",$("#worldlookingin").text());
			//demoInstanceInfo(this.element, $("#demo_info")); // This displays information about jPlayer's configuration in the demo page
		},
		customCssIds: true
	})
	.jPlayer("onProgressChange", function(lp,ppr,ppa,pt,tt) {
 		$("#pcent").text(parseInt(ppa)+"%");
	});


	$("#pause").hide();

	function showPauseBtn()
	{
		$("#play").fadeOut(function(){
			$("#pause").fadeIn();
		});
	}

	function showPlayBtn()
	{
		$("#pause").fadeOut(function(){
			$("#play").fadeIn();
		});
	}

	function playTrack(t,n)
	{
		$("#jquery_jplayer").jPlayer("setFile", t).jPlayer("play");

		showPauseBtn();

		$("#trackname").fadeOut(function(){
			$("#trackname").text(n);
			$("#trackname").fadeIn();
		});

		$("#pcent").fadeOut(function(){
			$("#pcent").fadeIn();
		});

		return false;
	}

	$("#worldlookingin").click(function() {
 		return(playTrack("audio/morcheeba_-_world_looking_in.mp3",$("#worldlookingin").text()));
	});

	$("#thesea").click(function() {
		return(playTrack("audio/morcheeba_-_the_sea.mp3",$("#thesea").text()));
	});

	$("#blindfold").click(function() {
		return(playTrack("audio/morcheeba_-_blindfold.mp3",$("#blindfold").text()));
	});

	$("#play").click(function() {
		$("#jquery_jplayer").jPlayer("play");
		showPauseBtn();
		return false;
	});

	$("#pause").click(function() {
		$("#jquery_jplayer").jPlayer("pause");
		showPlayBtn();
		return false;
	});

	$("#stop").click(function() {
		$("#jquery_jplayer").jPlayer("stop");
		showPlayBtn();
		return false;
	});

	$("#vmax").click(function() {
		$("#jquery_jplayer").jPlayer("volume", 100);
		return false;
	});

	$("#vmute").click(function() {
		$("#jquery_jplayer").jPlayer("volume", 0);
		return false;
	});

	$("#vhalf").click(function() {
		$("#jquery_jplayer").jPlayer("volume", 50);
		return false;
	});

});

</script>
booka