Triggering Audio in Chrome Mac problem


(Ralph) #1

I have a project I’m doing in Hype 3, pretty simple slideshow with audio and images animated. I originally wanted each slide to be triggered by On Scene Load but I see that audio in Chrome does not work. This is problematic for me as I now have to trigger the audio from a button.

But now I cannot get Jump To Scene to work for example I now have the following:

Scene 1
TimelineActions / pause timeline
Action1- Button / on mouse click triggers PlaySound
Action 2- Start Timeline

At 8 seconds ( when audio ends)
TimelineActions / jump To Scene/ Scene 2

Any help getting this to work??

R


#2

You might want to check out this example which listens for whether an audio file has ‘ended’:

If that doesn’t do the trick, can you share what you have so far?


(Ralph) #3

Will do, I’ll get back to you. R


(Ralph) #4

Ok just going over this as I just made a demo which will work in all browsers except Chrome. It has no audio controls and goes scene to scene using OnSceneLoad and audio loads fine

A bit mixed up about the code you sent, should I delete the OnSceneLoad code and replace with the code you sent?

If so I need to have the audio play when the scene loads and a timeline function to take the viewer to the next scene follow?

Change your audio_init_2() function to this. window.my_audio_2 = hypeDocument.getElementById(“my_audio_narration_2”); //hypeDocument.getElementById(“my_audio_narration_2”).loop = true; hypeDocument.getElementById(“my_audio_narration_2”).volume= .5; window.my_audio_2.onended = function() { hypeDocument.functions().show_hide_narration_2(hypeDocument, element, event) };

?? change getElementById to the name of my audio?
thats it?


#5

It’s hard to really tell you what to do since I don’t know what you’re doing – once you have a demo you are able to share I’d be happy to see what I can help with. The key thing you need to do is setup a thing to detect whether the audio is ended. That project does, but you’ll need to adapt it to your needs. The key part is:

window.my_audio_2.onended = function() {
// do something  
}

So you would use some part of that – and keep in mind that this also requires that your audio object is created outside of Hype’s audio system. This is the code you need to get going: https://www.w3schools.com/tags/av_prop_ended.asp, a nice snippet of code here: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_av_prop_ended

(Audio and Video use interchangeable code)


(Ralph) #6

Easier for me to give you the demo, Do I zip the file and drag here?


(Ralph) #7

https://www.dropbox.com/s/rgaymkysdq5adkt/Electrical%20Language3SlideDemo.zip?dl=0