Start playing the stream specified in the STREAM param, if any, or the last
played one through startPlaying(url).
void startPlaying(String StreamURL)
Start playing the file located at the specified URL. StreamURLcan be any valid
Java URL. The referenced file must be a WSAudio supported file. This will override the STREAM param of the applet, if any.
void stopPlaying()
Stop playing the stream, if any. This method will stop all of the WSAudio threads currently running (downloading, decoding and playing).
void setPaused(boolean b)
Pause (b=true) or restart
(b=false) playing the current stream.
When paused, the applet will stop returning audio data to the audio engine, while continuing download and decode of the stream until buffer space is available.
When restarted, the applet will continue returning audio data beginning at the point it was paused.
String getStreamURL()
Returns the String
URL representation of the currently playing WSAudio file, if any.
long getPlayLength()
Returns the total length of the current stream in number of samples.
This maybe 0 initially, if the engine has not read the header (status=STATUS_UNKNOWN, see below).
long getPlayPosition()
Returns the number of samples that had already been played.
long getPlayFrequency()
The nearest frequency to the desired one is returned, depending on the JVM capablities.
The desired one may be the one determined by the content, or the one
specified through setFrequency.
Note: JVMs previous to the 1.2 will always scale to 8KHz, because of VM limitations. The Java2 VM will
match the actual desired frequency.
int getPlayChannels()
Returns the actual playing channels.
Note: JVMs previous to the 1.2 will always scale to 1 channel, because of VM limitations. The Java2 VM will
match the actual channels of the content.
void setPreferredSection(int s)
The new WSA files are multi content files. They encode both 14.4 and 28.8 sections, and new ones will be
addeded in the future. With this method you tell the audio engine which of the sections you whish to play
(0=14.4, 1=28.8) before starting the stream.
This content selection requires repositioning on the file through HTTP byte ranges. If this fails, the first section
available on the file will be played.
For older SA or MA files, the selected section will always be 0.
long getPreferredSection(int s)
Returns the last desired section number.
String getSectionDescription(int s)
Returns a description of the content of the specified section number. This is valid after the sectionSelected event
has been received by the listener.
int getSectionsCount()
Returns the number of sections contained in the stream file. This is valid after the sectionSelected event
has been received by the listener.
String getTitle()
Returns the title contained in the stream file, if any.
boolean isAudioStarted()
Returns true if the AudioPlayer has been started. This may be false if still in wait state or if the header has not been
read yet.
booleain isRealized()
Returns true if WSAudio has already determined the type of decoder to be used, and created its instance.
The decoder is normally created once the section has been selected
(sectionSelected event).
restartPlayingAt(double pos)
Requests for repositioning. The position must be a value in the range 0.0-1.0 where 0.0 is the start of the stream, and
1.0 is the end.
int getStatus()
Returns the current status of the applet, as one of the following WSAudio public constants:
WSAudio.STATUS_UNKNOWN
The applet is in an unknown state. This may be in two cases:
- the applet has been just instantiated and is not playing anything, yet.
- the donwloading thread has not read the header of the audio file, yet (no length or frequency information available).
WSAudio.STATUS_BUFFERING
The applet is not receiving enough data to be decoded and the audio engine has already played the last available samples. This can happen when the connection is too slow.
WSAudio.STATUS_PLAYING
The applet is happily playing audio data.
WSAudio.STATUS_PAUSED
The applet has been paused calling the setPaused(true)method. Note that the
applet never decides to pause by himself.
WSAudio.STATUS_EOF
The applet has finished downloading, decoding and playing the stream.
WSAudio.STATUS_REFUSED
The server hosting the audio files refused connection for some reason.
long getFrequency()
Returns the frequency of the output audio data in Hz. This method will return valid data only after the
startPlayingmethod has been invoked.
This rapresents the resampling frequency regardless of actual output frequency of the AudioPlayer.
void setFrequency(long hz)
Sets the resampleing frequency of the audio data in Hz. If non zero, output frequency will be forced at the specified value. If zero, output frequency
will be the one of the selected content.
NOTE:
this method must be called before calling the startPlayingmethod, or it will have no effect on the current stream.
long getBufferingTime()
Returns the initial buffering time.
void setBufferingTime(long ms)
Sets the initial buffering time in milliseconds, that is the time the applet will wait before actually producing audio. When calling the startPlaying method, the
applet will start downloading and decoding the stream, but will wait the specified amount of milliseconds before starting the audio engine. This can help slow connection or very slow machines.
double getVolume()
Returns the current output volume (0.0-1.0). Default is 1.0.
void setVolume(double v)
Sets the output volume (0.0-1.0).
void setListener(WSAudioListener l)
Sets the listener for WSAudio events.
void addEvent(long decsecs,String msg)
When sinchronizing Java/JavaScript code to the audio engine, you will schedule time events through this method.
Specify tenth of seconds since the beginning of audio and the String message to be delivered.
The String message will be passed to the time event function. It is up to you to give meaning to this message.
You will need to specify the JavaScript function with the JSMETHOD parameter for the event to be delivered
to JavaScript.
void addRequestLine(String str)
If your system implements security schemes, you may find that the applet is not sending correct keys to the web server enabling communication. These keys
are usually HTTP request lines containing encrypted strings. You may use this function to add these request lines to the applet.
void clearRequestLines()
It may happen that the request keys used for a previous stream become invalid. You may clear any previous request line and add new ones with this method.