Skip to content

breily/jquery.player.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

jquery.player.js
----------------

* Use javascript to control the playback of MP3s with Flash

* by: Brian Reily (brianreily.com)
* based on plugin from digitalxero.net/music/index.html

* note that the best version to use is 0.2.  the code in the main
  directory is in progress.

* to compile your own music.swf, you need mtasc (www.mtasc.org):
  `mtasc -main music.as -swf music.swf -header 450:325:20 -version 8 -group`

* there is a test page at http://breily.github.com/jquery.player.js - note
  it is very bare, but should give you an idea of how the plugin works.

Usage
-----

* first, include jquery (testing done with 1.2.6)
* then include jquery.player.js
* then (for version 0.1):

// Initialize the player object
$("#test").player("music.swf", { options });
    // options you can use:
    // file               -> load a file and start playing immediately
    // artist, title      -> you can use the plugin to track these
    // volume             -> initial volume
    // interval           -> amount to change by when using volume("up"/"down")
    // next_song_callback -> function to call when a song ends

// Load and play a file
$("#test").load("test.mp3", { options });
    // options: artist, title (same as above)

// Control playback
$("#test").toggle();        // if playing, pause.  if paused, play
$("#test").toggle("play");  // explicitly play the file
$("#test").toggle("pause"); // explicitly pause the file
$("#test").toggle("stop");  // stop playback, set position to 0

// Control the volume
$("#test").volume();        // returns current volume value
$("#test").volume("up");    // increase volume by "interval" (default is 1)
$("#test").volume("down");  // decrease volume by "interval"
$("#test").volume("mute");  // toggles mute on/off
$("#test").volume(42);      // set the volume to 42    

// Get information about playtime (all in seconds)
$("#test").time();          // returns current time
$("#test").time("total");   // returns the total time of the file - note that
                            // this increases until file is fully loaded
$("#test").time(42);        // set position to 42 seconds

// Get information about bytes loaded
$("#test").bytes();         // returns number of bytes loaded
$("#test").bytes("total");  // returns the total file size, in bytes

Changes in Version 0.2
----------------------

* id3 tag support added:
    $("#test").id3("TIT2")

* a full list of tags is on the Adobe Flash help docs, under Sound.id3

* useful ones:
    title  -> "TIT2"
    artist -> "TPE1"
    album  -> "TALB"
    track  -> "TRCK"
    genre  -> "TCON"

* because of this, the plugin no longer tracks "artist" and "title"

* issue:  there have been some problems with getting the id3 tags from some
  mp3s.  continues even after they finish loading - this despite other programs
  verifying that they do in fact have tags.

Todo
----

Things I'm considering working on:   

* Try to figure out why id3 doesn't always work.

* Perhaps combine functions into one function, for example:
    $("#test").player("volume", "up");
    $("#test").player("time", 42);

About

Javascript control of Flash MP3 playback

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published