1

I am trying to build a sample application to help myself learn and prepare for an application I need to build at work, so I am following a tutorial on developer.apple.com, here... https://developer.apple.com/documentation/mediaplayer/displaying_a_media_picker_from_your_app The problem is, it says to extend MPMediaPickerControllerDelegate in your ViewController. So I did that, and Xcode is now yelling at me telling me that MPMediaPickerControllerDelegate is undefined type. I tried searching the web and found nothing, the only information I can find is the developer page, which doesn't contain really any relevant information about it, and a couple other tutorials that just show the exact same thing. There is really nothing special about my code, it is just a class declaration and the implementing of that class...

import UIKit

class ViewController: UIViewController, MPMediaPickerControllerDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

I have also tried importing MediaPlayer, but Xcode tells me that ViewController is part of MediaPlayer so the import will be ignored. Does anyone know how to use MPMediaPickerControllerDelegate or if it no longer around in swift 5, and if it is what is it replaced by. I mean, their own documentation on how to build a media application is quite literally that above code snippet, which doesn't work. Any help would be appreciated. Thank you.

Update.. Here is a screenshot showing what I mean about import MediaPlayer... enter image description here

Neglected Sanity
  • 1,770
  • 6
  • 23
  • 46
  • 1
    Adding `import MediaPlayer` is normally the correct solution. You have some other strange setup if `ViewController` is considered part of the MediaPlayer framework. – rmaddy May 09 '19 at 18:11
  • @rmaddy I updated my post with a screenshot showing what I mean. I try to import MediaPlayer and it gives me that message saying it's ignoring that import – Neglected Sanity May 09 '19 at 18:14
  • Crap! I solved it. I stupidly named my application MediaPlayer, so when importing MediaPlayer it was already a part of that module and not importing the kit from swift. – Neglected Sanity May 09 '19 at 18:16
  • @rmaddy lol, I was just seeing that as you were typing it. Thank you so much, I guess my brain isn't on today. – Neglected Sanity May 09 '19 at 18:17

0 Answers0