Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPMovieViewController crashing with Swift #5

Closed
gdroel opened this issue Jun 20, 2015 · 1 comment
Closed

MPMovieViewController crashing with Swift #5

gdroel opened this issue Jun 20, 2015 · 1 comment

Comments

@gdroel
Copy link

gdroel commented Jun 20, 2015

Hi Cameron, just wanted to say that you've done a really nice job on this project! However, I'm having trouble with some Swift code. Whenever I call the MPMovieController, a black screen shows. Here is some code:

    func makeMovie(){

        let settings:NSDictionary = CEMovieMaker.videoSettingsWithCodec(AVVideoCodecH264, withWidth: images![0].size.width, andHeight: images![0].size.height)
        let movieMaker = CEMovieMaker(settings: settings as [NSObject : AnyObject])

        movieMaker.createMovieFromImages(self.images) { (fileURL:NSURL!) -> Void in

            self.viewMovieAtURL(fileURL)
        }
    }

    func viewMovieAtURL(fileURL:NSURL){
        var moviePlayer : MPMoviePlayerController?
        moviePlayer = MPMoviePlayerController(contentURL: fileURL)
        if let player = moviePlayer {
            player.view.frame = self.view.bounds
            player.prepareToPlay()
            player.scalingMode = .AspectFill
            self.view.addSubview(player.view)
        }
    }

I think it may be a problem with the fileURL, though no errors are being thrown. The MPMoviePlayer just shows a black screen. Thoughts?

@gdroel
Copy link
Author

gdroel commented Jun 20, 2015

Sorry about that, I just had to make MPMoviePlayer an instance variable.

@gdroel gdroel closed this as completed Jun 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant