简体   繁体   中英

iOS, AVPlayer - looping MP3 segment

I am trying to loop a segment of an MP3 loaded from the users iPod library. By segment I mean, I don't want to loop the entire MP3 but only a section of it.

So say the MP3 is 4 minutes long, I have defined startTime, and endTime.

When the play button is hit, I seek the player to startTime and begin play.

I'm also subscribed to the event listener [AVPlayer addBoundaryTimeObserverForTimes:...] to be notified when my endTime has hit. At which point, I seek back to startTime and play.

** However, this does not provide a seamless loop - there is a split second where the sound stops before playing at startTime again.. My application is music making software, so it is important that the loop is perfect. Please help!

Apple has a Technical Q&A called Exporting a Trimmed Audio Asset .

Also, take a look at this thread , which deals with trimming an AVAsset audio file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM