2010-06-21 13 views
0

mon périphérique fonctionne sur OS4 GM et n'est pas présent dans Mediaplayer lors de la lecture. lors du test sur os3.1.3 cela fonctionne bien. Lorsque je cible à déployer sur OS4, il va résoudre ce problème, comment puis-je résoudre ce problème?Problème de compatibilité avec MediaPlayer sur OS4 lors du déploiement sous OS3

Voici mon code .h

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_2 
MPMoviePlayerController *theMovie; 
    #endif 
//On a 4.0 device, implement the MPMoviePlayerViewController 
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2 
MPMoviePlayerViewController *theMovie; 
    #endif 



//If iPhone OS is 3.1 or less, implement the MPMoviePlayerController 
    #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_2 
@property (readwrite, retain) MPMoviePlayerController *theMovie; 
    #endif 
//On a 4.0 device, implement the MPMoviePlayerViewController 
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2 
@property (readwrite, retain) MPMoviePlayerViewController *theMovie; 
    #endif 

.m

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_2 

        NSLog(@"__IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_2"); 

        AppDelegate = nil; 

        AppDelegate = [[UIApplication sharedApplication] delegate]; 

        [AppDelegate ForceHideNavigationBar]; 

        theMovie = nil; 

        // Register to receive a notification that the movie is now in memory and ready to play 

        [[NSNotificationCenter defaultCenter] addObserver:self 

                     selector:@selector(moviePreloadDidFinish:) 

                      name:MPMoviePlayerContentPreloadDidFinishNotification 

                     object:theMovie]; 



        // Register to receive a notification when the movie has finished playing. 

        [[NSNotificationCenter defaultCenter] addObserver:self 

                     selector:@selector(moviePlayBackDidFinish:) 

                      name:MPMoviePlayerPlaybackDidFinishNotification 

                     object:theMovie]; 



        // Register to receive a notification when the movie scaling mode has changed. 

        [[NSNotificationCenter defaultCenter] addObserver:self 

                     selector:@selector(movieScalingModeDidChange:) 

                      name:MPMoviePlayerScalingModeDidChangeNotification 

                     object:theMovie]; 



        theMovie = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:AppDelegate.PushLink]]; 

        theMovie.scalingMode = MPMovieScalingModeAspectFill; 
        [theMovie play]; 



    #endif    

        //On a 4.0 device, implement the MPMoviePlayerViewController 

    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2 

        // Initialize a movie player object with the specified URL 

        MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:AppDelegate.PushLink]]; 

        if (mp) { 



         self.theMovie = mp; 

         [mp release]; 

         //Present 

         [self presentMoviePlayerViewControllerAnimated:theMovie]; 



         // Play the movie! 

         self.theMovie.moviePlayer.movieSourceType = MPMovieSourceTypeFile; 

         [self.theMovie.moviePlayer play]; 

        } 

    #endif 

Répondre

3

Je vous souhaite cibler à la fois iOS3 et iOS4, vous ne voulez pas utiliser la compilation conditionnelle (#if déclarations) . La compilation conditionnelle se résout à la compilation mais vous voulez quelque chose qui puisse changer son comportement au runtime en fonction du système sur lequel l'utilisateur s'exécute.

Vous souhaitez réellement utiliser "liaison faible".

  1. Définissez votre SDK de base sur iOS4. Réglez le iPhone OS cible de déploiement à iOS3
  2. Déclarer les propriétés mais votre code de contrôle if ([MPMoviePlayerViewController class] != nil). Si ce n'est pas nil, utilisez le MPMoviePlayerViewController, sinon, utilisez l'ancien.

Pour en savoir plus sur la liaison faible, voir:

+0

merci Matt Gallagher – RAGOpoR

+0

j'ai un problème lors de l'intégration iAd lors de déploiement sur OS3-il une erreur comme ceci *** App terminant en raison de l'exception uncaught 'NSInvalidUnarchiveOperationException', raison: '*** - [NSKeyedUnarchiver decodeObjectForKey:]: ne peut pas décoder l'objet de la classe (ADBannerView)' – RAGOpoR