Permalink
Browse files

initial commit of files

  • Loading branch information...
0 parents commit 0fecec5f0ae28d101c9534909ce3e90d40e261bb Richard Hulse committed Nov 9, 2008
@@ -0,0 +1,2 @@
+.DS_Store
+_notes
BIN 0.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,119 @@
+/**
+ * Part of MooSound <http://widgets.rabidlabs.net/sound>
+ * I'm no AS expert, so some of this is probably pretty messy.
+ * @copyright 2007, 2008 Michelle Steigerwalt <msteigerwalt.com>
+ * @license LGPL 2.1
+ */
+
+import flash.external.*;
+import System.security.*;
+
+System.security.allowDomain("*");
+
+var preloaded:Object = new Object();
+var sounds:Object = new Object();
+var callback = "$.audioPlayer.events.";
+
+function preloadSound(url:String) {
+ var s = newSound(url, false);
+ preloaded[url] = s;
+}
+
+function newSound(url:String, streaming:Boolean):Sound {
+ var s = new Sound();
+ s.loadSound(url, streaming);
+ s.url = url;
+ s.registered = true;
+ sounds[url] = s;
+ s.onID3 = function ():Void {
+ for (var prop in s.id3) {
+ flash.external.ExternalInterface.call(callback+"registerID3", url, prop, s.id3[prop]);
+ }
+ };
+
+ s.onLoad = function (success:Boolean):Void {
+ if (success) {
+ s.loaded = true;
+ flash.external.ExternalInterface.call(callback+"onSoundLoaded", s.url);
+ }
+
+ };
+
+ s.onSoundComplete = function ():Void {
+ flash.external.ExternalInterface.call(callback+"onSoundComplete", s.url);
+ };
+
+ return s;
+}
+
+function startSound(url:String, position:Number, volume:Number, pan:Number):Boolean {
+ if (position > 0) { var pos = position / 1000; }
+ else { var pos = 0; }
+ var s = preloaded[url];
+ if (s.registered == true) {
+ s.start(pos);
+ return true;
+ } else {
+ var s = sounds[url];
+ if (s.registered == true) { s.start(pos); }
+ else { var s = newSound(url, true); s.start(pos); }
+ s.start(pos);
+ return true;
+ }
+}
+
+function setVolume(url:String, vol:Number):Void {
+ var s = sounds[url];
+ s.setVolume(vol);
+}
+
+function setPan(url:String, pan:Number):Void {
+ var s = sounds[url];
+ s.setPan(pan);
+}
+
+function getProgress(url) {
+ s = sounds[url];
+ if (s == null) { return 0; }
+ return Math.floor(s.getBytesLoaded() / s.getBytesTotal() * 100);
+}
+
+function getBytesLoaded(url) {
+ s = sounds[url];
+ if (s == null) return 0;
+ return s.getBytesLoaded();
+}
+
+function getBytesTotal(url) {
+ s = sounds[url];
+ if (s == null) return 0;
+ return s.getBytesTotal();
+}
+
+function getPosition(url) {
+ s = sounds[url];
+ return Math.floor(s.position);
+}
+
+function stopSound(url) {
+ var s = sounds[url];
+ s.stop();
+ s.position = 0;
+}
+
+function getDuration(url) {
+ s = sounds[url];
+ return s.duration / (getProgress(url)/100);
+}
+
+flash.external.ExternalInterface.addCallback("startSound", this, startSound);
+flash.external.ExternalInterface.addCallback("preloadSound", this, preloadSound);
+flash.external.ExternalInterface.addCallback("getBytesLoaded", this, getBytesLoaded);
+flash.external.ExternalInterface.addCallback("getBytesTotal", this, getBytesTotal);
+flash.external.ExternalInterface.addCallback("setVolume", this, setVolume);
+flash.external.ExternalInterface.addCallback("setPan", this, setPan);
+flash.external.ExternalInterface.addCallback("getPosition", this, getPosition);
+flash.external.ExternalInterface.addCallback("getDuration", this, getDuration);
+flash.external.ExternalInterface.addCallback("stopSounds", this, stopSounds);
+flash.external.ExternalInterface.addCallback("stopSound", this, stopSound);
+flash.external.ExternalInterface.call(callback+"onFlashLoaded", true);
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,52 @@
+The jQuery Audio Player plugin
+
+by Richard Hulse (richard.hulse@radionz.co.nz)
+Copyright (c) 2008, Radio New Zealand Limited
+
+==================
+NOTES
+==================
+
+The plugin will load an MP3 or OGG file and play it. The running time and current
+volume can be fetched and displayed.
+
+There is much to do, such as:
+
+* Add id3 data population of player title and description
+* Allow an audio metadata structure to be used on the load function
+* Playlist functionality
+
+The player will be implemented as a set of plugins so that anyone can build the exact functionality
+that they want.
+
+==================
+To Use the example
+==================
+
+Add the jQuery library v 1.2.6 and an MP3 or OGG file to the working directory and edit example.html to play it.
+
+==================
+LICENSE
+==================
+
+The code written by Radio NZ is released under the GPL V2.0 or later.
+
+The license used by other code is noted in the source, but is compatible.
+
+==================
+RELEASES
+==================
+
+# Version 0.1
+
+Initial Release
+
+
+
+==================
+CREDITS
+==================
+
+The player was inspired by MooSound. (We had to use jQuery.)
+
+The flash player is mostly the same as the one used by MooSound with some changes.
@@ -0,0 +1,47 @@
+*{font-size:100%;margin:0;padding:0;}
+body{font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04;}
+img{border:none;}
+
+h1{margin:10px;}
+
+.hide {left:-9999px;position:absolute;}
+
+#player-wrapper{position:relative; border:1px solid #310C04; background:#DDD;
+ width:500px;height:120px;z-index:99;}
+
+#time-wrapper{position:absolute; top:65px; left:390px;}
+
+#counter{padding:5px; margin:10px; border:1px solid gray; width:5em; text-align:right;
+ font-size:14px; font-weight:bold; background:#FFF;}
+
+#volume{ position:absolute; left: 300px; top:120px; z-index:100; font-size:14px;}
+
+ul{margin:5px 0 0 0;padding:0;list-style:none;}
+li{margin:0;padding:0;}
+
+.items li span{ display:block;}
+
+span.title{font-size:1.0em;padding:0 5px; font-weight:bold;}
+span.desc{display:block; padding: 2px 5px 0 ; font-weight:normal; font-size:0.8em; }
+
+#controls{margin:0px 10px; position:absolute;top:60px;}
+#controls li{list-style:none;display:inline;padding-right:5px;}
+#controls li input{
+ background:url(play-icons.png) no-repeat top left;
+ text-align:center;
+ border:none;
+ color:#000;
+ font-family:arial,sans-serif;
+ text-decoration:none;
+ width:50px; height:50px;
+}
+#controls li #last{background-position:0 0;}
+#controls li #stop{background-position:-50px 0;}
+#controls li .play{background-position:-100px 0;}
+#controls li .playing{background-position:-150px 0;}
+#controls li #next{background-position:-200px 0;}
+#controls li #quieter{margin-left:20px; background-position:-300px 0;}
+#controls li #louder{background-position:-250px 0;}
+#controls li a span{position:absolute;left:-9000px;}
+
+
@@ -0,0 +1,134 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Audio Player example</title>
+<style type="text/css" media="screen">
+ @import 'example.css';
+</style>
+<script type="text/javascript" src="jquery-1.2.6.min.js "></script>
+<script type="text/javascript" src="jquery.audioplayer.js "></script>
+<script type="text/javascript">
+
+jQuery(document).ready(function(){
+
+ // events must always come first as DOM elements could be updated from the initialise function
+ // e.g. the time and volume DOM containers
+
+ $(document).bind('soundVolumeChange', function(e, m){
+ $('#volume').html( updateVolume(m.volume) );
+ });
+
+ $(document).bind('soundStop soundPause', function(e, m){
+ $('#play').removeClass( 'playing');
+ });
+
+ $(document).bind('soundPlay', function(e, m){
+ $('#play').addClass( 'playing');
+ });
+
+ $.audioPlayer.initialise( {
+ mp3Player : "audioplayer.swf",
+ expressPlayer : "expressInstall.swf",
+ });
+
+ // Add your example files here.
+ //$.audioPlayer.load( 'review.ogg');
+ $.audioPlayer.load( 'robot2.mp3');
+
+ $('#play').click( function(){
+ if( $.audioPlayer.isPlaying()){
+ $.audioPlayer.pause();
+ }
+ else{
+ $.audioPlayer.play(0);
+ }
+ });
+
+ $('#stop').click( function(){
+ $.audioPlayer.stop();
+ });
+
+ $('#quieter').click( function(){
+ $.audioPlayer.quieter();
+ });
+
+ $('#louder').click( function(){
+ $.audioPlayer.louder();
+ });
+
+ $.periodic(updateTime, {frequency: 0.1});
+
+ function updateVolume( vol ){
+ $('#volume').html( vol + '%');
+ }
+
+ function updateTime(){
+ var time = $.audioPlayer.elapsedTime();
+ $(".seconds").html(formatTime( time ));
+ return true;
+ }
+
+ function formatTime( dur ){
+
+ var difference = Math.floor(dur);
+ seconds = difference % 60;
+ difference = (difference - seconds) / 60;
+ minutes = difference % 60;
+ difference = (difference - minutes) / 60;
+ hours = difference % 24;
+
+ seconds = ((seconds < 10) ? "0" : "") + seconds;
+
+ if(hours > 0){
+ return hours + ":" + minutes + ":" + seconds;
+ }
+ else{
+ return minutes + ":" + seconds;
+ }
+ }
+
+})
+
+</script>
+</head>
+<body>
+ <h1>Audio Player</h1>
+ <div id="player-wrapper">
+ <!-- Section for displaying data about the item -->
+ <div id="playlist">
+ <h2 class="hide">Current Item</h2>
+ <ul class="items">
+ <li><span class="title">This is the title of the item up to 64 characters in width XXXX</span><span class="hide"> - </span>
+ <span class="desc">This is the description of the item and can be up to 128 chars, which is a lot longer than the title and would extent out to here X.</span></li>
+ </ul>
+ </div>
+
+ <!-- Section for showing the current clip time -->
+ <div id="time-wrapper">
+ <h2 class="hide">Current time</h2>
+ <div id="counter">
+ <div class="seconds">0:00</div>
+ </div>
+ </div>
+
+ <div id="player">
+ <h2 class="hide">Player Controls</h2>
+ <ul id="controls">
+ <!-- li><input width="50" type="image" height="50" alt="Last" src="0.gif" id="last"/></li -->
+ <li><input type="image" alt="Stop" src="0.gif" id="stop"/></li>
+ <li><input type="image" alt="Play/Pause" src="0.gif" id="play" class="play"/></li>
+ <!-- li><input type="image" alt="Pause" src="0.gif" id="pause"/></li -->
+ <!-- li><input type="image" alt="Next" src="0.gif" id="next"/></li -->
+ <li><input type="image" height="50" alt="Quieter" src="0.gif" id="quieter"/></li>
+ <li><input type="image" alt="Louder" src="0.gif" id="louder"/></li>
+ </ul>
+ </div>
+ </div>
+
+ <div id="volume">
+
+ </div>
+
+</body>
+</html>
Binary file not shown.
Oops, something went wrong.

0 comments on commit 0fecec5

Please sign in to comment.