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.
You can initiate playback like so:
movie.play()
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
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
You can check to see whether or not a movie is currently playing, like this:
if movie.playing {
//do stuff
}
//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()
}