MPMoviePlayerController - error-message

Discussion in 'iOS Programming' started by Danneman101, Mar 5, 2009.

  1. Danneman101 macrumors 6502

    Aug 14, 2008
    Since <embed sound> in UIWebView html-pages does not seem to work in 2.2 (worked fine in 2.0/2.1, see my post at, Ive had to find another way to play sounds.

    Im trying to use the MPMoviePlayerController instead, and have used the attached code below.

    However, I keep getting the following errors:
    "Linking /Volumes/.../ (2 errors)
    (x) ".objc_class_name_MPMoviePlayerController", referenced from:
    literal-pointer@_OBJC@_cls_refs@MPMoviePlayerController in myViewController.o
    (x)"_MPMoviePlayerPlaybackDidFinishNotification", referenced from:
    _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in myViewController.o
    symbol(s) not found
    collect2: Id returned 1 exit status"

    // in myViewController.h
    // --------------------------
    #import <MediaPlayer/MediaPlayer.h>
    // in myViewController.m
    // --------------------------
    playMovieAtURL:@"test.wav";  // calls the function playMovieAtURL, and is placed within another function.
    	MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:theURL];
    	theMovie.movieControlMode = MPMovieControlModeHidden;
    	// Register for the playback finished notification.
    	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; 
    	// Movie playback is asynchronous, so this method returns immediately.
    	[theMovie play];
    // When the movie is done,release the controller.
    	MPMoviePlayerController* theMovie=[aNotification object];
    	[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
    	// Release the movie instance created in playMovieAtURL
    	[theMovie release];
    Does anybody have a clue to what the mumbo-jumbo in the error-message is about?

    Alternatively, can you suggest a better objc-method of playing mp3-sounds (need to be mp3 because of the compression - app becomes way to big with wav/aif)?
  2. Danneman101 thread starter macrumors 6502

    Aug 14, 2008
    you have to add the MediaPlayer.framework to the frameworks of your project

    to do this:
    right click on frameworks, add existing framework, select the MediaPlayer.framework (which is located in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/library/Frameworks )

Share This Page