FSAudioController music transitions - ios

I'm using FSAudioController to play mp3's from my service. I have a URL list and I'm playing songs by shuffling the list.
What I want to do is, 5 seconds before the current song ends, next song will start playing and there will be a soft transition between songs. But I couldn't find anything about how to play 2 songs at the same time.
I thought about using 2 different FSAudioController objects, but I wanted to ask if there is smarter way to do it first.
Thanks in advance!

Unfortunately FSAudioController does not support crossfade option so you will have to use 2 different FSAudioController objects.

Related

Two AVPlayer videos out of sync (Swift)

I have two AVPlayer() items playing videos of the same duration (10 seconds). The goal is to have them loop and stay in sync with one another. I add them as sublayers of the same UIView and then call player.play() on each one of them.
The problem though is that as code execution obviously has the slightest delay as one is called after the other one, the videos are out of sync (although only a few milliseconds, it is noticeable).
I do not have the option to create an AVMutableComposition as I have seen other posts suggest, so is there anyway to have two separate players truly stay in sync and play EXACTLY at the same time?
Thank you!
If you want to achieve the sync, you should load the videos separately with AVPlayer and observe the AVPlayerItemStatus property of each player. Only when all of the players have the status .readyToPlay you can loop through the players and set the .rate property.
Edit:
You can also synchronize them by using setRate(_:time:atHostTime:). Don't forget begin loading media data using preroll(atRate:completionHandler:) before calling setRate. Basically:
wait for readyToPlay
preroll(atRate:completionHandler:) when all players are ready
setRate(_:time:atHostTime:) when all players were prerolled

How does Vine looping video playback work on iOS?

Vine loops videos without any pauses in between loops. I've tried creating an AVPlayer that plays the video from the beginning whenever it ends. This introduces a slight lag between every loop. I'm looking for suggestions of ways to avoid this lag.
I have considered creating much longer videos out of repeating short clips. Am I missing some obvious solution?
Thanks.
You can use AVPlayerQueue to queue up the videos (in this case the same one multiple times), and it will handle playing them in sequence.
For example
iPhone Smooth Transition from One Video To Another

Gapless and non freeze playing of player items using AVQueuePlayer

I have some issue with avqueueplayer like app freezing for 2-3 seconds when each item ends in the queue. I am using queueplayer to play the records one after the other without gap. In order to achieve no gaps b/w player items, I need to load the assets for a player item in advance. I load assets for current playing player item and next player item so that there will be no gap at the end of 1st record. As the 1st record ends, I add 2nd player item to queueplayer to play and also load assets for 3rd player item.
In this way my playerqueue always contains a single player item but asset loading will be done for current playing item and next playing item. This will keep moving as the new records are added.
I found that a freeze of half a second is observed in new iOS devices and around 3-4 seconds in old iPod devices like iPod 4?
Can I know how we can achieve gapless and yet non freeze UI experience?
Thanks
Try lifting your requirement to only have a single player item in the queue.
An AVQueuePlayer will operate more effectively at item transitions if there is an item in its queue beyond what's currently playing.
"Loading" media can mean a few different things, and it's not clear what you're doing. Maybe you're downloading media outside of AVFoundation, building an AVAsset or building an AVPlayerItem. The work you're doing or deferring will vary depending on the kind of media (e.g an mp4 vs an HLS stream). Even if you "preload" everything (which is much more complicated for HLS media), AVFoundation still has more work to do that it won't start until the AVPlayerItem is put in a player. It has to set up a render pipeline specific to the media it needs to play back, and then start the rendering process. AVQueuePlayer can achieve gapless playback by starting some of that process before playback for that item needs to start. The queue player is also efficient about its use of resources in that it won't start loading items far down the queue until it needs to.

Do i need to stop MusicPlayerController first before i play to next song in iOS?

In my app , i have to play songs from iPod Library with MPMusicPlayerContrller's iPodMusicPlayer.
I just want to know , in my app , first song is playing from Album and when i want to play another song from Playlists that selected from UITableView do i need to use stop function [self.player stop]; before change next songs?
Or i can directly play without stop current playing song?
Thanks for your help.
no need to stop.my question is "Why to stop?". no,never nothing, there is no need of stop.
ios already given you facility of playing new song from playlist through the properties.
if you stops it & again play it,its just wastage of execution time.
Since you probably use skipToNextItem or skipToPreviousItem it's perfectly legit to use them directly.
Documentation for MPMusicPlayerController.

AVtouch problem

In my app, I select one song from tableView and played in default player,
and then when i back to playlist (i.e tableview) and select another song
then BOTH songs played simultaneously.
How I solve this problem ? I want to play when another song select then that selected song must played and previous one should be stopped.
Please HELP.
Thanks in advance.
Hurray Problem solved....
Problem: Multiple songs overlapping in player.
Reason : Multiple instance creation of AVAudioPlayer.
Solution: Create only one instance at launch, and when play called
then [audioplayer stop] then play (using flags avoid multiple creation).
Thanx to all.

Resources