Continue Sound With Play Button


#1

I understand that exporting hype as a movie will not allow users to click and interact with what I have created.
I understand that this can only be done interactively if I export as html 5.

But html5 doesn’t allow users to start and stop the presentation as there are no controls.

So I decided the place images of play and pause buttons.
It works fine except with Audio. If I pause the timeline and pause the audio, how do I get the user to resume the timeline and audio from the same point where he stopped it. I can’t see any option to continue the audio from the point where it was paused.

Is my understanding correct and is my assumption correct?

JH


#2

Animation timelines are separate from the timelines of audio files. If you want to pause both a timeline and an audio element, you’ll need to specifically target both using JavaScript:

hypeDocument.pauseTimelineNamed('timelineName');
document.getElementById("audioelementid").pause;

You can then resume audio by running:

document.getElementById("audioelementid").play;

A bit more info on controlling audio with JavaScript can be found here.


#3

Thanks for this. I have absolutely no knowledge of Javascript or any other programming language.

But here is what I did.

I selected the pause image on the scene and then I went to >>Actions Inspector >> On Mouse Click >> Run Javascript >> New Function.

Then I pasted the two pause lines in there before the } bracket.

I then edited the first line to stopSound so that the name of the JS file changed.

I also changed hypeDocument.pauseTimelineNamed('timelineName'); to hypeDocument.pauseTimelineNamed('Main Timeline');

Then I went back and previewed it in the browser.

It didnt stop the audio when i clicked the pause image.

Any ideas?


#4

Did you set the element ID of your audio element to be audioelementid or whatever text you have in this function? You can change the ID of an element by selecting it and modifying the ID field in the Identity Inspector (image).

document.getElementById("audioelementid").pause();

It would be great to see your document.


#5

Hi @Jetheat

Is it not pause(); @Daniel

Jetheat, here is a document you can have a look at to see the 2 different ways you can achieve this with code or using the inspector audio-manipulation.zip (548.7 KB)

I would suggest looking at the link Daniel posted as well to familiarise yourself with the way Javascript can be used to manipulate audio and video.

Hope this helps!

D


#6

Here is what I have set up.


#7

If you’re having issues it would be great if you could attach a zip file of your document and share it with us.


#8

Daniel - I have audio playing and pausing nicely using this technique but… I’d love to be able to pause audio and switch to another scene but still be able to switch back and unpause it.

That should be possible shouldn’t it ? At the moment when I go back the sound is resetting which is not great as there’s a lot of it. Alastair


#9