Twine: improved YouTube background audio macros

This code is largely based on some original macros posted to the Google Group by, er, somebody. These take a YouTube video ID and plays the audio of that video invisibly in the background of your Twine game. The player will require Flash installed, of course. (Last updated 16/3/14)

What I've done is upgrade it in the following ways:
* The volume slider is removed, on the basis that most authors will probably not have much call for it. Also, it required jQuery and jQuery UI, which not only inflated the footprint of the script, but may have interfered with other jQuery-using Twine scripts.
* It supports multiple sound tracks per story, and lets you play them simultaneous with each other if you so wish.
* The script will attempt to preload all of the videos, ensuring that they play as soon as their macros are called. (Note: currently it only preloads the tracks from the start, so this performance gain may not be seen when starting playback from the middle of the track.)
* A few more macros are provided, roughly in line with my HTML5 audio macros: <<unloopbgm>> and <<pausebgm>>.
* The code has less implicit globals. (This is a meaningless distinction.)
* There should be more informative error messages for specific error codes.

The macro names themselves are similar, but I made the following changes: <<playbgm>> now plays the audio once, and <<loopbgm>> causes it to constantly loop. Otherwise, they function identically.

Note: For browser security reasons, local HTML files are prohibited from accessing network files through a Flash embed. So, you have to test these macros by running the game from a web server.

Usage examples
*<<playbgm iHBWZn9re0U 32>> plays the YouTube video starting from 32 seconds in.
*<<playbgm iHBWZn9re0U>> plays the YouTube video from the beginning, or resumes it if it was paused.
*<<stopbgm iHBWZn9re0U>> stops the sound track.
*<<loopbgm iHBWZn9re0U>> makes the sound track constantly loop (although it may not quite be seamless).
*<<unloopbgm iHBWZn9re0U>> stops it from looping.
*<<pausebgm iHBWZn9re0U>> pauses the sound track.
*<<stopbgm iHBWZn9re0U>> stops playback and resets its position to the start.

Feel free to report any bugs to @webbedspace.

TwineMacros-YouTubeAudio-2.1.0.txt3.13 KB


I can't seem to get this

I can't seem to get this Youtube macro to work... Even when I put it up live, the music just doesn't kick in.