Skip to content

Instantly share code, notes, and snippets.

@seka
Created October 31, 2014 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seka/2d9d48ab567db52e531a to your computer and use it in GitHub Desktop.
Save seka/2d9d48ab567db52e531a to your computer and use it in GitHub Desktop.
AssetLibraryから動画を再生する際の設定 - Setup when playing a video from AssetLibrary (サンプル - Sample)
func setupAssetMovieContents() {
let file = NSURL(string: "assets-library:// ~ hogehuga ~ ")
let assetLibrary = ALAssetsLibrary()
assetLibrary.assetForURL(
file
, resultBlock: {
(asset: ALAsset!) in
if asset != nil {
let rep: ALAssetRepresentation = asset.defaultRepresentation()
var mvc = MPMoviePlayerViewController()
mvc.view.frame = CGRectMake(860, 0, 800, 350)
var vc = mvc.moviePlayer
vc.contentURL = rep.url()
vc.view.frame = CGRectMake(865, 10, 800, 330)
vc.scalingMode = MPMovieScalingMode.Fill
vc.shouldAutoplay = false
vc.setFullscreen(true, animated: true)
self.scrollViewOfProfile.addSubview(vc.view)
}
}
, failureBlock: {
(error: NSError!) in
println("Error!\(error)")
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment