SimpleAudio can be rather useful to be a SimpleVideo - some quick hacking has interesting results #213
WakeReality
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The track queue ability of SimpleAudio is appealing to me for HTML5 video elemnt.
I downloaded the SimpleAudio.js file and renamed it to SimpleVideo.js and changed the var SimpleVideo = to window.SimpleVideo = and starting playing from there.
I didn't rename the 'audio' variable name, as the code heavily uses it. But I did change the document.createElment('audio') calls to 'video' elements and it still worked perfectly fine in playing audio.
The createElement is just there in the webpage, it never gets placed on the output. Which for an audio element that has no visual representation, this makes sense.
Then I added a function to the SimpleVideo object:
Usage in Twine story:
And when you call it, it surfaces it. Obvious a detach function paired with it would be useful. Could also take the element as a parameter instead of hard coding '#story'.
Pausing the track works fine, etc. It's really just a need to attach (append) it some existing visible DOM element. Appending it to Story allows you to move between passages while still playing - which behaves like audio would too.
I'm curious if anyone else has done this, has code to share, etc. Thank you.
Beta Was this translation helpful? Give feedback.
All reactions