What is the advantage of loading AVPlayerItem with AVURLAsset than url

As the title says, what advantage can be done over the other?

With an asset:

MPMediaItem *song = [self.itemCollection objectAtIndex:self.currentIndex];
NSURL *songURL = [song valueForProperty:MPMediaItemPropertyAssetURL];
AVAsset *asset = [AVURLAsset URLAssetWithURL:songURL options:nil];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
[self.myPlayer replaceCurrentItemWithPlayerItem:item];

      

From URL:

MPMediaItem *song = [self.itemCollection objectAtIndex:self.currentIndex];
NSURL *songURL = [song valueForProperty:MPMediaItemPropertyAssetURL];
AVPlayerItem *item = [AVPlayerItem playerItemWithURL:songURL];
[self.myPlayer replaceCurrentItemWithPlayerItem:item];

      

Update

Immediately after some games, I noticed the following:

There is one problem with remote control events when using the old method (resource): 1. Lock the screen and wait for the next song to play. 2. When the next song starts, press the Home button twice to bring up the controls. 3. Tap pause: nothing happens. 4. Press pause again: the music is paused.

Now there is no problem with remote control events because it gets called on the first try. This pauses music (i.e. [self.myPlayer pause]

) that isn't working - until you try it again.

Not sure why this is, but for me this is the reason for using a url method.

+3


source to share





All Articles