Spacebar play/pause

Can I add spacebar as play/pause to custom behavior? How would I do that?

Thank you!

see :

Hi Mark - thanks! I saw that thread and tried it, but I am not using the video/audio feature. I am using the rectangle element and then writing code for the video and audio. So, I’m sure it’s a simple fix with some javascript, but I don’t know what it is! I’m happy to provide any information necessary to find this out.

Thanks so much,
Carey

Thats exactly what does threads refer to!.
Go to the top of the referred thread and read down..

It is all there already.. :smile:

Hey Mark - thanks so much. The issue I’m having is that I still want my audio and video to autostart. But, I want spacebar to be a button to toggle pause and play, too. Is that possible? I don’t see that in the thread. In the thread, I see having to play the audio/video with the button that is set up.

Thanks!

Can you elaborate more on what you are trying to play/pause?

If you want to use the spacebar in conjunction with playing/pausing timelines in Hype, you’d instead use the following APIs to determine play state and continue or pause:

if(hypeDocument.isPlayingTimelineNamed('timelineName') == true) {
    hypeDocument.pauseTimelineNamed('timelineName');
} else {
    hypeDocument.continueTimelineNamed('timelineName', hypeDocument.kDirectionForward, false);
}

Hi, I tried that code but it interfered with the video autoplay. It had the sound autoplay but the video didn’t, I had to press the play button for the video to play and then both were going.