0

I done all these coding still unable play the video.....

  1. Info.plist file adding in the UIBackgroundModes array the audio element.

  2. And added these two methods in AppDelegate.m

    [[AVAudioSession sharedInstance] setDelegate: self];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    
  3. and this methods in the player class

    (void)viewDidAppear:(BOOL)animated
    {
      [super viewDidAppear:animated];
      [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
      [self becomeFirstResponder];
    }
    
    - (void)viewWillDisappear:(BOOL)animated
    {
        [mPlayer pause];    
        [super viewWillDisappear:animated];
        [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
        [self resignFirstResponder];
    }
    
    (void)remoteControlReceivedWithEvent:(UIEvent *)event {
            switch (event.subtype) {
                case UIEventSubtypeRemoteControlTogglePlayPause:
                    if([mPlayer rate] == 0){
                        [mPlayer play];
                    } else {
                        [mPlayer pause];
                    }
                    break;
                case UIEventSubtypeRemoteControlPlay:
                    [mPlayer play];
                    break;
                case UIEventSubtypeRemoteControlPause:
                    [mPlayer pause];
                    break;
                default:
                    break;
            }
        }
    
Roby
  • 3
  • 5

0 Answers0