Youtube
element
description
Creates a YouTube video player.
syntax
newYoutube(ELEMENT_NAME: string, YOUTUBE_REFERENCE_CODE: string, ["show controls"])
-
ELEMENT_NAME
: The name of the newly-created element. -
YOUTUBE_REFERENCE_CODE
: The YouTube video reference code (the string that comes afterwatch?v=
in the YouTube video URL). -
["show controls"]
(optional): Enables the YouTube video player controls, which are disabled by default.
since
beta 0.3example(s)
+ Youtube elements use Youtube’s IFrame player API. Support might vary across browsers (e.g., preloading seems more efficient on Firefox than on Chrome).
@newYoutube("myVideo", "aFPtc8BVdJk")
+ Youtube elements let you add youtube videos to the page using their reference code (what comes after watch?v= in the video’s URL) as seen above Action commands
youtube.log
syntax
.log()
description
Note: since beta 0.4, blank parentheses default back "play"
. In beta 0.3, they default back to "all"
.
example
click to expand
@newYoutube("myYoutube", "code")
$ .log("play", "buffer")
@ .play()
@ .wait()
- Will start playing a Youtube video without showing it. Each play and each buffer event will add a line to the results file.
youtube.once
syntax
.once()
description
Will disable the Youtube video after it has finished playing.
example
click to expand
@newYoutube("myYoutube", "aFPtc8BVdJk")
$ .once()
@ .print()
@ .play()
@ .wait()
@,
@newButton("validate", "Validate")
@ .print()
@ .wait()
- Shows a video on the page and starts playing it. Playback will become disabled after it has finished.
youtube.pause
syntax
.pause()
description
Pauses the video.
example
click to expand
@newYoutube("mcgurk", "aFPtc8BVdJk")
@ .print()
@ .play()
@,
@newTimer("preview", 1000)
@ .start()
@ .wait()
@,
@getYoutube("mcgurk")
$ .pause()
- Starts playing a mind-blowing video demonstrating the McGurk effect, waits 1 second and pauses the video.
youtube.play
syntax
.play()
description
Starts playing the video. If you did not use print
before, the video will not be visible on the screen but sound will start playing anyway.
example
click to expand
@newYoutube("mcgurk", "aFPtc8BVdJk")
@ .print()
$ .play()
@ .wait()
- Plays a mind-blowing video demonstrating the McGurk effect.
youtube.stop
syntax
.stop()
description
Pauses the video and moves it back to the beginning (position = 0s).
example
click to expand
@newYoutube("mcgurk", "aFPtc8BVdJk")
@ .print()
@ .play()
@,
@newTimer("preview", 2000)
@ .start()
@ .wait()
@,
@getYoutube("mcgurk")
$ .stop()
- Starts playing a mind-blowing video demonstrating the McGurk effect, waits 2 seconds and stops the video. The video will start over from the beginning next time it is played.
youtube.wait
syntax
.wait()
description
Waits until the video has ended before evaluating and executing the next commands.
example
click to expand
@newYoutube("mcgurk", "aFPtc8BVdJk")
@ .print()
@ .play()
@,
@newButton("validation", "Validate")
@ .print()
@ .wait()
@,
@getYoutube("mcgurk")
$ .wait("first")
@,
@newButton("thanks", "Thank you for watching")
@ .print()
@ .wait()
- Starts playing a mind-blowing video demonstrating the McGurk effect and adds a button onto the screen. If the button is clicked before the video has ended for the first time, it waits until the end before printing a button saying Thank you for watching.
Test commands
youtube.test.hasPlayed
syntax
.test.hasPlayed()
description
Tests whether the end of the video was reached at least once. Note that the video need not have fully played, if the position was manually set before reaching the end.
example
click to expand
@newYoutube("myYoutube", "aFPtc8BVdJk")
@ .print()
@,
@newButton("Next")
@ .print()
@ .wait(
$ getYoutube("myVideo").test.hasPlayed()
$ .failure( newText("Please play the video first").print() )
@ )
- After the button Next is pressed and the printed video isn’t played yet, the program will throw error saying that the video should be played first.
youtube.test.playing
syntax
.test.playing()
description
Tests whether the video is currently playing.
example
click to expand
@nnewYoutube("myYoutube", "aFPtc8BVdJk")
@ .print()
@,
@newButton("Next")
@ .print()
@ .wait(
$ getVideo("myYoutube").test.playing()
$ .failure( newText("Please let the video finish first").print() )
@ )
- After the button Next is pressed and the printed video is still playing, the program will throw error saying that the video should be finished first.