VIDEO Missing argument for parameter "bundle"

I want a video on my app.



I have this code


import UIKit

import MediaPlayer

class MPMoviePlayerController : UIViewController {

override func viewDidLoad() {

super.viewDidLoad()

var url:NSURL = NSURL(string: "/Users/valeriasiragusa/Documents/1/ESAME APP PORTFOLIO/Portfolio/Portfolio/MPMoviePlayerController.swift")!

var moviePlayer = MPMoviePlayerController(contentURL: url) //Missing argument for parameter "bundle" in call

moviePlayer.view.frame = CGRect(x: 20, y: 100, width: 200, height: 150)

moviePlayer.movieSourceType = MPMovieSourceType.File

self.view.addSubview(moviePlayer.view)

moviePlayer.prepareToPlay()

moviePlayer.play()

}

}



Can you solve my problem?

Answered by OOPer in 15665022

Why do you name your class same as the existing class you want to use?

Change this:

class MPMoviePlayerController : UIViewController {

to:

class MyMoviePlayerViewController : UIViewController {
Accepted Answer

Why do you name your class same as the existing class you want to use?

Change this:

class MPMoviePlayerController : UIViewController {

to:

class MyMoviePlayerViewController : UIViewController {

it did not solve my problem.

This is my app https://drive.google.com/file/d/0B9IhsIvn5gynZWN3TmFxSE9TZzA/view?usp=sharing

Can you help me?

It seems your project is first written in Swift 1.1 or before.

Start with using Edit>Convert>To Latest Swift Syntax...


You may find some more problems. But they are other issues. You should create new threads according to each issue.

I find another issue related to your code in the opening post.

You create NSURL form the file path of your development Mac.

var url:NSURL = NSURL(string: "/Users/valeriasiragusa/Documents/1/ESAME APP PORTFOLIO/Portfolio/Portfolio/MPMoviePlayerController.swift")!

Your Mac's paths are not visible from apps. You need to create NSURL from your app bundle.

var url = NSBundle.mainBundle().URLForResource("GameShark", withExtension: "mp4")

One more thing needed is make your app bundle include the video resource.

See the File Inspector of GameShark.mp4, and check TARGET MEMBERSHIP for your app.


Hoping the app work as you expect soon. Good luck.

VIDEO Missing argument for parameter "bundle"
 
 
Q