Author
Travis Kirton


Creating Movies

Included with the default installer are two movies, "halo" and "haloGray", that you can expriment with:

To create a movie, simply specify the file name of the image like so:

let m = Movie("halo.mp4")

Unlike images, you have to specify the file extension of a movie.

Play()

You can initiate playback like so:

movie.play()

Pause()

You can pause playback like so:

movie.pause()

Pausing keeps the movie’s current time, when you hit play() again it will resume from where it left off

Stop()

You can stop playback like so:

movie.stop()

Stopping resets the movie’s current time, when you hit play() again it will resume from its beginning

Playing

You can check to see whether or not a movie is currently playing, like this:

if movie.playing {
    //do stuff
}

Example

//create a movie and play it automatically
let movie = Movie("halo.mp4")!
movie.width = canvas.width
movie.play()
canvas.add(movie)

canvas.addTapGestureRecognizer { locations, center, state in
    movie.playing ? movie.pause() : movie.play()
}