Is it possible to play sections of a movie without using timers to do the pausing and unpausing? For example I have a movie loaded into MPMoviePlayerController, the user taps and the first section of the movie is played then the movie is paused, on the second tap another section is played and so on. Setting the initialPlayBackTime and endPlayBackTime of MPMoviePlayerController doesn't help as endPlayBackTime gets updated only when stop is called (could it be a bug?), but stopping causes an annoying flicker.
I don't think so... You need the timer and that's it.
Related
Hey so I am playing some background music as soon as my app starts. Like a menu song, and it is looping forever throughout the game. I would like to change the music as soon as you hit the start game button. Just so I can have a different menu and game songs. I tried
backgroundMusicPlayer.play()
playBackgroundMusic("MUSIC.wav")
I did this in my touchesBegan method but of course every time you touch the screen the song is going to start over and over again. Any ideas how I can do this? Thank you in advance
While the game starts,if a user touches the initial screen,then it could be identified with a tapGestureRecognizer,in the corresponding class file.
I prefer tap recognising than touchesBegan ,so that, when user touches the screen ,you could play the music via
backgroundMusicPlayer.play()
playBackgroundMusic("MUSIC.wav")
and stop this by backgroundMusicPlayer.stop()when moving on to MENU page.
Then the music wont get played everytime user touches the screen.
I hope this works.
Simply use AVFoundation. Follow this basic tutorial to play audio as soon as the ViewController loads, then on clicking the start button stop the audioPlayer.
I have multiple moviefiles. That i would like to make a playlist of. How can i assign the next and previous buttons to go to the next movie.
I've tried to find a solution for this for a long time, but i cant seem to find a answer for this?
And i'm not talking about dismissing the current MPMoviePlayerController and opening a new one with the new video.
You can use contentURL property of MPMoviePlayerController for playing new video.
If you set this property while a movie is playing, that movie pauses and the new movie begins loading. The new movie starts playing at the beginning.
I have a bit of a strange problem. I have a music app that uses the [MPMusicPlayerController iPodMusicPlayer]. Everything is fine, notifications are fired for track changes and changes in playback state.
I have one screen where the user needs to review one single song, I don't want him to go on to the next song in his queue. Since there is no delegate method for when a track WILL change (only DID change), to prevent the music player from continuing to the next track I use a new [MPMusicPlayerController applicationMusicPlayer], give it iPodMusicPlayer's currently playing song and all is well. No new tracks to continue to, and I'm not touching the original iPodMusicPlayer queue so in theory, when I close this screen and use the iPodMusicPlayer again, all should be perfectly fine.
However, when the user is done on this screen and closes it, iPodMusicPlayer is now suddenly broken, notifications are not called and when I put the app to the background, music stops playing, causing me to believe that iPodMusicPlayer is now actually applicationMusicPlayer.
Okay so my question is basically: I need a way to prevent the music player to continue on to the next track in the queue. Switching to applicationMusicPlayer with one track seems to break stuff, as explained above. What's the best solution?
EDIT: because this might be a bit difficult to understand, I created a small project to show the problem: https://github.com/kevinrenskers/MPMusicPlayerControllerTest. Open the app while music is playing, see that the play button behaves correctly. Now open the popup, close it again and the play button is broken.
I found a solution to my problem: set the repeatMode to MPMusicRepeatModeOne and then catch the MPMusicPlayerControllerNowPlayingItemDidChangeNotification notification. You can stop the playback and you never continue to the next track. Once I'm done with the second screen I reset the repeatMode to the original value.
I have multiple MPMoviePlayerControllers in one view.
When a play one of them while there is already another one is playing,
the playing one is "Paused"(I'm not sure the real state it is, but more like "Stucked")
How can i know which one of the MPMoviePlayerControllers is Stucked?
Its restriction by apple, in single view controller only single movie player will get played. If one player is in play state and you are trying to play another then first player will get in pause/stop mode.
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.