Strange behaviour in iOS Today Widget with AVPlayer - ios

I'm really getting crazy on this, so I'd ask for some help.
I'm coding a little widget that presents two UIButton the user can tap, once pressed the widget adds a notification to the app, if the button is pressed again the notification will be deleted.
Initially I added a sound to the touch of the button and worked ok with AVPlayer, then I decided to use the haptic engine to give feedback to the user so I deleted the AVPlayer call to stop the sound: guess what? the button continues to play the sound! I've commented the code I used to play the sound, how can it still play the sound?.
The strange thing is that one button has got this strange behaviour, while the other just works fine (only haptic engine), it sounds like a bug but I'm a rookie and it should be my fault somewhere.
Any idea?

Related

iOS twice click for music controller to start

I have music app and I have fully implementation for background but I found one bug when I refactor my design with SwiftUI. When I click pause in my music app and go to backround and try click to play from native iOS music controller I need click twice for play.... And I can't find why? then when it starts playing everything works fine
maybe someone faced a similar problem?

Programmatically refresh screenshot in iOS7 multitasking screen?

I have a music player app which implements background audio. I’m trying to update the screenshot in the iOS7 multi-tasking switcher when the track changes. So, if I background the app during Song A, it finishes and Song B comes on, if I then go into the tray I’d like to see a screenshot showing Song B’s artwork, title, etc.
I’ve done some digging and not managed to find any way to tell iOS to update short of implementing Background Fetch and going all out with that. Is there another means of doing this, something I can call to tell it to refresh it when my tracks change?
Apple does not provide any means of doing this. Even iOS own media player does not have this ability.

Hold and Release in Xcode (Sound)?

So, I just basically want to use AVFoundation Kit for playing my sound. I have the play method set, but I want to be able to hold down the button and play the sound that way rather than tapping it first. Once I release the button, I want the sound to stop. Simple: Hold down to play sound and then release your finger to stop the sound like a piano. Help please! Thanks.
If you right click on the button in IB you should be able to link the
Touch down
and
Touch Cancelled
button links so that it they both call the same method or they each call a different method one to stop the sound and one to start it.
you might also want to check out this
forum
hope this helps

MPMusicPlayerController: combine iPodMusicPlayer and applicationMusicPlayer to prevent continuing to next track

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.

application is crashing while user exits from fullscreen mode in mpmovieplayer

hi folks we do have a video file in our application,every thing is going fine except one,i.e the application crashes when user exits from fullscreen mode while the movie is playing and also when we pause the movie in fullscreen mode and minimize it,the video starts from the beginning i tried searching whether there is any notification available to notify but of no use plz help me out.thx in advance.
atlast after studying a lot about mpmovieplayer class refernece i could find the answer for my question which i had posted yesterday.The reason for that was i was not able to provide all the available notifications i need, now i had mentioned each and every notification for entering into full screen,exit the fullscfreen and also playbackfinished now its working fine.The only problem is when i press the toggle screen it maximizes perfectly and plays from the current playbacktime but that not the case when i minimize the screen the video plays from the begining.

Resources