building an audio player

Klaus Major klaus at major-k.de
Tue Jul 12 13:53:50 EDT 2005


Xin chào Ban,

> Xin chào Klaus,
>
> I am new to Revolution.  I am building an audio player.  So far I  
> got the play, stop, next, previous buttons work
>
> Do you have any idea to do the pause button and I want to use the  
> slider to control the audio id user want to play fast or play back  
> (you know what I mean)

you mean the user clicks (and holds the mouse!) on the fastforward  
button
and the sound plays very fast, until the user releases the mouse again?

Hint:
To be able to control the sound like you want to, you must use a  
"player“ object!
If you just use "play ac xyz" then you do not have much control over  
the playback!
No fast forward/backward etc...

In that case i use a button (2 buttons, on for forward and one for  
backwards)
with this script, this is the fastforward button:

on mousedown
    set the playrate of player "your audio playername here" to 2
   ## plays double speed...
   ## This is the "normal" behaviour of such a button, i think ;-)
end mousedown

on mouseup
     set the playrate of player "your audio playername here" to 1
end mouseup

on mouserelease
   set the playrate of player "your audio playername here" to 1
end mouserelease


That's all :-)
...
set the playrate of ... to -2
...

In the fast backward button.

> I want to have a volume control to control the sound

Simply use a "slider", vertical of horizontal.

Set the startvalue to 0
The endvalue to 100

And put this into the script of the slider:

on scrollbardrag t_value
    set the playloudness of player "your audio playername here" to  
t_value
end scrollbardrag

Done :-)

The message "scrollbardrag" is being sent to Revolution continuously
while the user drags the slider. The message can have 1 parameter,
the current value of the slider, so this script will work in realtime.

Hope this helps.

> BTW I am using the scrolling list field to list the audio files and  
> let user click on each song....it works
>
> Please help
> Thank you

Không có chi. (I just love Google ;-)

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list