AVAudioPlayer along with seek bar and play pause button - xcode

I want to design audio player view to play my audio file.
I am bit confused about AVAudioPlayer working.
When I use AVAudioPlayer, it plays my audio file very well.
But I also want PLAY/PAUSE button and seek bar which will show the progress bar.
My question is that,
is there any inbuilt library or code that I can directly inherit and apply...?
or do I need to create those buttons and seek bar programatically and add them on view while playing the file...?
Thanks in advance.
I tried to search but all shows AVAudioPlayer working,
Nothing found four PLAY/PAUSE buttons additions

I am currently making a music player, and I made my own control view using UIButtons for Play, Pause, Next, Previous, and a UISlider for seeking. There is no built in AvAudioPlayer controls that I know of for this purpose.

Related

Play/Pause button on the apple tv remote is not working while the video is playing with AVPlayerViewController

I am playing the video through AVPlayerViewController in tvOS (Xamarin tvOS). I am pausing and resuming the video with Play/Pause button on the apple tv remote. I am using the PressesBegan method to get the event on click of Play/Pause button. This is working fine on the simulator but not on the actual devices. On the actual devices, we are not getting the events for pressing the Play/Pause button. We tried it on Apple TV 4K (version 12.11) and Apple TV (version 11.4).
This is only happening when I play the video through AVPlayerViewController otherwise it works fine. I tried UITapGestureRecognizer, PressesEnded method, and also the RemoteControlReceived method. But still, there is no help. Any help will be much appreciated.
https://github.com/lewixlabs/TvOS-PlayBack-Sample-App/blob/master/TvOS%20PlayBack%20Sample%20App/ViewController.cs
Your app will not receive Pause (or Play/Pause) button events when playing video. This is expected--and documented--behavior. The system redirects the action to the "Now Playing" app's handler (which is AVPlayerViewController in this case).
You didn't say why you were trying to intercept Play/Pause...
If you're trying to disable pausing, you should take a different approach; for example, you could disable user interaction on the root view of the AVPlayerViewController (this disables not just play/pause but pretty much all controls). You could also disable the playback controls. Remember that there are multiple ways for a user to pause, including clicking the touch surface, or using a different type of remote or telling Siri to "pause," neither of which will result in regular pause button events.
If you're trying to determine when the video is paused, you could key-value observe the "rate" property of the player (the rate could also to change to zero for other reasons, e.g. because playback reached the end).
Add a UITapGestureRecognizer to ViewController and allow the UIPressType.PlayPause press type.
var tap = new UITapGestureRecognizer(() =>
{
Console.WriteLine("Remote PlayPause button pressed");
})
{
AllowedPressTypes = new NSNumber[] { new NSNumber((long)UIPressType.PlayPause) }
};
this.View.AddGestureRecognizer(tap);

How can I stop background audio played by other apps?

I have an app for WP7, using BackgroundAudioPlayer as we need to play in the background. The problem is, when there's already an app playing audio in the background, I can't get my AudioPlaybackAgent work, the previous music just keep playing.
The document introduced this way,
BackgroundAudioPlayer.Instance.Close();
by which I can only close the audio that is played by myself or Zune, but it doesn't work when the audio is played by other apps.
So is there a way to close all the playing audio?
OK I fixed it.
What I did to get it play is like this, first I set a track to the player:
BackgroundAudioPlayer.Instance.Track = ...;
Then an OnPlayStateChanged event will fire in the background agent, where I call the BackgroundAudioPlayer.Instance.Play() method. This seems to work great.
But if the background player is already being used by another app, the PlayState won't change to TrackReady when I set the track, and consequently the event won't fire.
To fix this, I simply call the .Play() method in the main UI thread, right after setting the track. And it works.

IOS Music Control in Background

I am trying to find the solution to have the control of play/pause when my app is playing the own music in Background. I am using AVAudioPlayer and didnĀ“t find the way to implement this controls. When the app is "close" the music play perfectly but I have to open the app again to pause or change music when needed.
Any solution ?
If you're running iOS 4 you can try putting the app in the background whilst playing music, and then pressing the home button twice for the 'multitasking' bar.
Swipe the bar to the right, which shows you the normal playback controls for Music, YouTube, etc.
If you use the AVAudioPlayer I'm quite sure you can use those same controls to control your app's playback of media.
Bryan
*EDIT does using the remote on the iPhone headphones work?

Embedding quicktime player in Cocoa app

I'm wondering if it's possible for me to embed the quicktime player in a cocoa app. The default QTMovieView is kind of ugly, and the quicktime player window has all the features I need in it, such as full screen, and the maintain aspect ratio button.
I'd like it to operate transparently to the user though. I'd rather avoid making them launch the quicktime app. I'd also like to be able to position the window on the screen. Also, I need to be able to access the current playhead position, and capture when they stop the movie. Any ideas on how I might go about doing this? Or would I have to build out my own custom video player?
A third party component would be fine as well if any exist. I'm just looking for that same quicktime player appearance with the black control bar that appears when hovering over the screen.
Or would I have to build out my own custom video player?
Yes. There is no (reliable) way of getting QuickTime player to integrate into your application.
You should make a subclass of QTMovieView, and maybe use some subviews for the controls.
You can hide the controls if the QTMovieView if you do not like them. In IB switch off Show Controller property.
Alternatively, you can use QTMovieLayer.
Also, it is easy to create your own set of controls that will work directly with the properties and methods of the QTMovie.

Avoid animation of AirPlay button in MPVolumeView

I am developing an iPhone application that supports AirPlay using MPMoviePlayerController. When the user click on the play button Player custom View is added to a window. Hence didMoveToWindow is getting called. In this method I create MPMoviePlayerController and load it into custom player view.
I set allowsAirPlay of MPMoviePlayerController to YES. Add MPVolumeView to my custom Player view by removing all the volume related controls from MPVolumeView except AirPlay Control.
The problem is that AirPlay control appears after small delay of player loaded. Why does this happen? Is it because of animation added to AirPlay button? If so, how do I avoid this animation?
There's currently no [appstore safe] way to disable or interact with that animation.

Resources