How to call javascript functions from other functions (multiple times in a row)?


(Raleigh Green) #21

Hi Hans-Gerd,

Thanks so much for taking a look at this!
I downloaded and tried to open your example, but it wouldn’t open. Instead got this message: Document Version Incompatibility - The document you are trying to open was created with a newer version of Hype and cannot be displayed.

Are you using Hype 4? :wink:
My current version is 3.6.7.

Would you possibly be able to send me a version that I can open with Hype 3?

Thanks again!


(Hans-Gerd Claßen) #22

ah … sry

FYI: i removed the audiofile to get it up here …AudioScrubberWHowler3.hype.zip (36.8 KB)


(Raleigh Green) #23

And…it works!!!

Wow, thank you so much for your help with this HansGerd!
Can’t tell you how grateful I am for your assistance.
And also thanks so much for hooking up the duration as well.
Just fantastic.

Sunny day indeed :slight_smile:

Have a wonderful week and all the best to you.


(Raleigh Green) #24

Hi h_classen!

I wanted to thank you again for the help with the audio player.
It’s working wonderfully with my project!

However, the last feature I’m needing to add to this audio player is the ability to click on the audio scrubber and jump to that time in the timeline.

I’ve been trying to modify the clickToTime(); function in Mark Hunte’s video-controller example to get this to work in my project. But the setup is different enough that I’m having no luck.

Do you by any chance have any thoughts on what I can do to get a function like clickToTime() working with my audio player?

Here is the example file I’m working with:

AudioPlayer.zip (1.6 MB)

I’d so appreciate any guidance you (or anyone else) might be able to offer.
Thanks so much!


(Jonathan Deutsch) #25

There’s a bit of complexity in getting the events entirely correct because you have the group as your scrubber; you may want to think about changing the knob to have your on drag action for it to work correctly. I got the basics by adding a “hit box” rectangle element with an opacity of 0% above the slider control. This was to get the width and hit target exacting. Then I added an on mouse click action that looks like:

 	var sliderWidth = hypeDocument.getElementProperty(element, 'width');
 	var percentComplete = event.offsetX / sliderWidth;
	song.seek(percentComplete * song.duration());

Here’s the demo file:

AudioPlayer-fixed.hype.zip (1.6 MB)

But like I said, it isn’t perfect due to the drag on top.


(Raleigh Green) #26

@jonathan awesome.
This is exactly what I was trying to do, thanks so much!
I took your advice and put the drag action on the knob (makes sense and works better).
I also turned the bounding box of the scrubber group into the ‘hit box’ and adjusted its size and placement to get precise targeting.
It’s working great now :slight_smile: .
Thanks so much for pointing me in the right direction!
All the best and thanks again.


(Jonathan Deutsch) #27

Great, glad you got it all together!