Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play multiple Audio Files with AVPlayer

I'm trying to play multiple sounds at the same time.

The approach initially I've taken was to create several players , but it seems wrong one.

What's the best way to play several audio files at the same time.

Is it through making them AVAssets, but in this case how would I stop and play them whenever I want.

Really appreciate your help.

The reason I need AVPlayer is to fetch sounds from the iPod Library.

I finally got an answer from TechSupport of Apple Dev Team and it seems I'm on the right track when I decided to use several AVPlayer.

like image 926
Rouslan Karimov Avatar asked May 31 '11 21:05

Rouslan Karimov


People also ask

How many videos can you play at once on avplayer?

Experience the exhilaration of watching and controlling up to 16 Awesome Videos all at the same time on one screen! Go ahead, we know you’ll love it, especially with that exciting AV collection. ; ) Why Use AVPlayer Instead of Other Media Players? Because watching AV one at a time is just so boring!

How to play and pause audio in avaudioplayer?

Then, declare the following state linking to AVAudioPlayer before the body variable and after the struct: As you can see, we have set up a text with 2 buttons below, one for playing the audio, the other one for pausing it. the syntax is pretty simple: audioPlayer.pause () and audioPlayer.play ().

What is the avaudioplayer class for?

The AVAudioPlayer class has other properties to control playback (such as the number of times to loop) as well as properties that give you information about the sound file (such as the duration). Check out the Apple class reference document for more information! Have you teamed up with a partner to develop an app?

Why should I use avplayer?

Moreover, you can save your favorite videos in playlists for immediate reloading any time you want. And finally, AVPlayer is optimized to prioritize hardware decoding using the graphics card to be as efficiently as possible playing video files, while taking advantage of software codecs for maximum compatibility using the CPU whenever necessary.


1 Answers

For every sound you want to make make a new AVPlayer.

NSURL *url = [NSURL URLWithString:pathToYourFile];
AVPlayer *audioPlayer = [[AVPlayer alloc] initWithURL:url];
[audioPlayer play];

like image 53
Sam Baumgarten Avatar answered Sep 21 '22 05:09

Sam Baumgarten