I'm using MPMusicPlayerController in my application. I'm setting a queue using method "setQueueWithItemCollection". I'm able to play the songs, move to prev/next songs etc.
But how can I make MPMusicPlayerController play some 5th song from the queue?
when you set the queue, save the queue somewhere else that you can access.
if you want to play the fifth song, use MPMusicPlayerController.nowPlayingItem= [[queue items] objectAtIndex:4] and it will play the fifth song. you don't have to skip 5 times.
you have to maintain another list of queue in your application.
Then everytime, when you to jump to another song, get players current item, compare it from your array iterating through it and at the same time use skip to prev or next song from music player.
no other solution found.
Related
I've tried multiple flutter plug-ins to stream and play and pause music but as of currently, I haven't yet figured out a simple way to implement play and pause, whilst having the ability to avoid music overlapping, I want so that when the current song is playing, if I were to press play on new music track, the current song playing will stop and play the newly pressed song. I've tried flutter_sound, audio player, audio file player, and flute music player but I can't seem to figure out how to do this.
If it is possible either using one of these or a new plug-in, is there a way to implement what I have just described.
The library you seek is more of a multi-track player than a player. Which does not currently exists AFAIK.
The simplest way is to act according to the status of the tracks (which should be given by the player).
Roughly, what I suggest: have something that keeps the status (e.g. paused, playing, completed) of each track. (e.g. List of Tracks) When you press play on track 2 or track 1 finishes playing, you set to 'completed' (or as you wish) the track 1 and set to 'playing' the track 2.
Have a listener on the status of the current track and voila (for autoplay). When the track completes, notify the listener to call a function to start the next one on your list. When you press another track, set to 'completed' the current track and to 'playing' the track you pressed, then notify listeners.
Any library letting you know the status of a track is good enough for your purpose.
I am creating an app that has a playlist and uses the MediaPlayer library. When a song ends I don't want the next song to start. I tried to use the MPMusicPlayerControllerNowPlayingItemDidChangeNotification to pause the music player when the song changes, but the song starts to play before I get the chance to stop it. I also tried to use KVO to track the changes to musicPlayer.currentPlaybackTime, but I only receive messages when i manually change the playback time. I can't find any information about this problem anywhere.
In my app I have shuffle and repeat off, and create a queue with only one song in it, then send that to the music player. When the song finishes, there aren't any other songs in the queue, so it stops playing.
That being said, the latest iOS update has stopped reporting the correct playback state when the song finishes and is reporting it as paused when it used to be stopped. Not sure if that's a side-effect of the above method or not.
Are you calling:
player.beginGeneratingPlaybackNotifications()
before adding the observers?
Is there a way to update the 'listened to' status of an MPMediaItem from the iPod library?
I've tried using MPMusicPlayerController in iPodMusicPlayer mode and it does not mark the podcast as listened to once it finishes playing.
As far as I can see it's not possible to change media attributes from MPMusicPlayer controller.
The only thing you could try play back the podcast and jump to the last second, then play back the last second (and turn the volume to 0 for that second).
But this is no good way as well because, you have play back something this causes a stop of every other iPod playback.
I am getting a list of songs and its corresponding images from a url.The url is a json url. When i click the list a corresponding song is played. I have used AVFoundation Framework to play the song. Now the issue is that i need to play the next song after the playing of first song is completed. The corresponding images also must load. If i click the next or previous button the corresponding songs must be played. What is the best possible mechanism to attain it???
I have read about the Audio Queues and Audio Units but not sure how to use them. I'll be really helpful if i am provided with some sample code of how to do it.
The easiest thing is to just place an If statement in audioPlayerDidFinishPlaying which is what is called after each sound is played (if playing them with an AVAudioPlayer).
You can also use that to update whatever images you need to as well based on the name.
I have implement an application.In which there is list of videos.when user touch on the video then video play in MPMoviePlayer.But when video is finished then i want to play another video automatically.Is it possible?
Yes. Do you want it to play another one randomly? You could do that. Or do you have an NSArray that contains all the different MPMoviePlayer URLs to play in order? If you do, then loop through the array objects and play each. You will have to have a MPMoviePlayerPlaybackDidFinishNotification to know when each videos finish so you can start the next one.