スイフト用
オブザーバーを追加
let defaultCenter: NSNotificationCenter = NSNotificationCenter.defaultCenter()
defaultCenter.addObserver(self, selector: "moviePlayerPlaybackStateDidChange:", name: MPMoviePlayerPlaybackStateDidChangeNotification, object: nil)
関数
func moviePlayerPlaybackStateDidChange(notification: NSNotification) {
let moviePlayerController = notification.object as! MPMoviePlayerController
var playbackState: String = "Unknown"
switch moviePlayerController.playbackState {
case .Stopped:
playbackState = "Stopped"
case .Playing:
playbackState = "Playing"
case .Paused:
playbackState = "Paused"
case .Interrupted:
playbackState = "Interrupted"
case .SeekingForward:
playbackState = "Seeking Forward"
case .SeekingBackward:
playbackState = "Seeking Backward"
}
print("Playback State: %@", playbackState)
}