I’m trying to have a simple draggable element play a sound as its dragged back and forth. So I have a small rectangle that can be moved over a timeline of three seconds and at say one second a play audio event should fire. I’ve tried doing that with both the play sound command and by launching Javascript and by starting another timeline but all these methods fail.
Is this possible. If I select continue after drag the sounds will fire but not if I effectively try and use the drag as a scrubber.
Not near my Mac to check the hype document but the record player time jumping example is ace. Hopefully I might be able to adapt that to get what I’m trying to do to work.
Basically a slider that plays progressively through notes of a chord, as you move the slider back and forth, (each note is a separate file).
then forget about my first example …
create a timeline with stoppoints, add a play audio behaviour.
create the slider which on drag controls the timeline with option continuing on.
though, won’t work on iPad. If important rethink you timelineapproach.
Timeline actions won’t fire during a drag. I would like to add more options in the future to allow this. In the meantime you can add a Run Javascript action to your On Drag handler and use currentTimeInTimelineNamed to figure out if you should play audio.
The code below assumes you have added your audio as suggested in here and that you want the audio to play when that point is hit either forwards or backwards.
var currentTime = hypeDocument.currentTimeInTimelineNamed('dragTimeline');
var soundTime = 2;
if (window.pastTime == true) {
if (currentTime < soundTime) {
var myAudio = document.getElementById("myAudio");
myAudio.currentTime = 0;
myAudio.play();
window.pastTime = false;
}
} else {
if (currentTime > soundTime) {
var myAudio = document.getElementById("myAudio");
myAudio.currentTime = 0;
myAudio.play();
window.pastTime = true;
}
}
Sorry been away so thankyou. That works to play the sound at the specified time.
I should now be able extend that out to include other sounds at points in the timeline, so many thanks.