百度智能云

All Product Document

          Multimedia Cloud Processing

          Quick Start

          Set Access Key

          Before creating the player instance, you must set Access Key. Or the procedure is unable to feature properly

          Before the use of SDK, users need to get the Baidu AI Cloud Access Key. Please see Apply for Authentication Document to get the LicenseID.

          Realize the protocol BDCloudMediaPlayerAuthDelegate in your AppDelegate type, and set license ID:

          [[BDCloudMediaPlayerAuth sharedInstance] authenticateLicenseID:@"80871356198739456000p"
                                                       
            completionHandler:^(NSError *error) {
              if (!error) {
                  NSLog(@"success"); }
                  }];
                  
                  - (void)authStart {
              // Certification started.
          }
          - (void)authEnd:(NSError*)error {
              // If the error is empty after authentication, it indicates that the authentication is completed successfully.
          }

          Play Video

          BDCloudMediaPlayerController is the core class of SDK, and the video play and various controls are realized through this class.

          The following code demonstrates:

          • Create player;
          • Set video play address;
          • Play the video
          //Suppose self is an instance of UIViewController. 
          //Create player and set video paly address. 
          self.player = [[BDCloudMediaPlayerController alloc] initWithContentString:@"<url>"]; 
          
          //Add the view of player into the view of self. 
          [self.view addSubView:self.player.view]; 
          
          //Add layout for the player view. 
          // ...
          
          //Set auto play after video initialization. 
          self.player.shoudAutoPlay = YES; 
          
          //Initialize the video. 
          [self.player prepareToPlay]; 

          After the address to play the video is set, the player needs to call prepareToPlay method to initialize the video files.

          After initializing, the player sends BDCloudMediaPlayerPlaybackIsPreparedToPlayNotification notification and set the attribute of isPreparedToPlay as YES. If the shouldAutoplay property is ‘YES , it automatically calls ‘play for playback; if the ‘shouldAutoplay property is ‘NO, it waits to call ‘play ` for playback.

          Pause and Continue Playing

          Pause the video being played:

          [self.player pause]; 

          Continue to play the paused video:

          [self.player play]; 

          Change the Playing Position

          SDK provides multiple methods to change play positions.

          When initializing

          Before calling prepareToPlay method, you can set initialPlaybackTime to set the starting play seconds.

          self.player.initialPlaybackTime = 10.0f; 

          When Playing

          There are two ways to change the play position when playing:

          • Set the ‘currentPlaybackTime ` property;
          self.player.currentPlaybackTime = 10.0f; 
          • Call seek method
          [self.player seek:10.0f]; 

          Stop Play

          Call stop method to stop playing

          [self.player stop]; 

          After stopping play, the player sends BDCloudMediaPlayerPlaybackDidFinishNotification notification.

          Previous
          iOS-Player-SDK-Introduction
          Next
          Help Documentation for Baidu iOS Player-1.0-