Playing OGG Vorbis files with Sash
The Sash.Vorbis extensions allows the user to play .ogg files. When you feel
like adding some interesting music to your weblication, remember that artists
need to make a living, too.
1. Sash.Vorbis
This object is the actual Vorbis file player. It has standard commands (play, pause, seek, etc.). Set the current file and you're ready to play.
Constructor
|
VorbisFile(string filename)
|
Creates a Vorbis file object that can be played.
var song= new Sash.Vorbis.VorbisFile(filename);
|
Method
|
void setCurrent(sashIVorbisFile vorbisFileObject)
|
Sets the currently active
VorbisFile object to vorbisFileObject
. All other Sash.Vorbis functions refer to the currently
active file.
|
void play()
|
Play the active file from its
current position. (Acts as resume is the file was paused)
|
void pause()
|
Stops playing the active file,
but remembers its current position.
|
void reset()
|
Resets the current file's position
to the beginning (0 seconds).
|
void seek(double absoluteSeconds)
|
Sets the play position of the
active file to absoluteSeconds after
the beginning.
|
double tell()
|
Returns the current play position
(time elapsed) of the active file as a number of seconds.
|
void forward(double skipSeconds)
|
Moves
skipSeconds ahead of the current play position of the active file.
|
void back(double skipSeconds)
|
Moves
skipSeconds back from the current play position of the active
file.
|
2. Sash.Vorbis.VorbisFile
You must open music files using the VorbisFile
constructor. To actually play a file, you must first set it as the current
file (see Sash.Vorbis). VorbisFile
objects provide rudimentary support for reading meta-tags.
Property
|
readonly string name
|
This read-only property returns
the name of the file as a string.
|
Method
|
string getTag(string tagName)
|
Returns the contents of the meta-tag
represented by tagName as a string.
|
3. Quick example
This is all you need to do to play a song:
var song= new Sash.Vorbis.VorbisFile('~/ogg/DeepPurple/Burn.ogg');
Sash.Vorbis.setCurrent(song);
Sash.Vorbis.play();
Wing Yung,
Stefan Atev
Last modified: Thu Mar 21 15:33:27 EST 2002