How to unload sf2 from an AKMidiSampler - audiokit

I want to change the loaded sound on an AKMidiSampler but there’re memory leaks if I just load a new sound into the same AKMidiSampler.

Related

AVPlayer audio out of sync after seek

I use PlayerKit in one app to stream video from Cloudinary.
Everything works fine until I use seek to move video forwards or backwards.
I pause the video, use seek to move it to time I wish. After that the video plays fine but audio only starts after 20-30 seconds and is out of sync.
I've tried waiting for it to buffer, and different options on AVPlayerItem, Asset and Player but to no avail. One thing I did notice is that audio is not buffered while video is paused, it starts buffering audio only when I play the video.
PlayerKit is just a wrapper for AVPlayer and uses AVPlayer methods and listeners to inform me of buffering time and playing state so it's not up to the pod.
I resolved it by switching from mp4 to m3u8.
m3u8 is a playlist information file so I was then able to stream from cloudinary instead.

Blocking default player to play audio files ios

My App has functionality to record and play audio using AVAudioRecorder/AVAudioPlayer respectively. Whenever I download an audio file from the server, the file is opened automatically using the default player with a black screen as shown:
However, I actually have my own user interface to play audio files. How can I block this option programmatically?

iphone-loading sound files quickly

I have a space shooter game I am making. I want to play a sound every time a user hits the button fire. This is a short .wav file of about half a second in length. Also, when the user dies, I have an explosion .mp3 file to play. Since the fire button can be clicked very rapidly, I need to play sounds quickly. I used some avaudio player code previously where I make a new audioplayer every time I need to fire, but this crashes occasionally if I fire very quickly. Any suggestions on ways to play sound files very quickly? (including some example code in you answer would be great)
if you using MPMediaPlayback you can try prepareToPlay

Downloading a video from a remote URL into device and streaming it via AVPlayer

What I'm doing currently is that, I have a remote URL containing a MP4 file. I download that into a file using NSData and NSFileManager (as I want to cache the file). Now I start to play the file using AVPlayer.
All this works. But the problem is,when the video is getting buffered after a few seconds, the playback cannot be resumed.
Note:
The state of the AVPlayer does not change to Pause.
The current time of the video continues to run even though the video has stalled.
Is there anyway I can pause the video before the buffer happens?
Thanks in advance.
Fixed it myself. Created a file and the downloaded data is written into the file only after say 1MB of it has been downloaded and the player is made to pause when say 90% of this data has been read. This way the player doesn't stall.In the background the file continues to be downloaded. This way the size of the file will continue to increase even if the player is playing/pausing the video.

Reducing the initial delay when playing remote video content

Hi using MPMoviePlayerController to stream video into the app. However, it takes a long time to load and I want to be able to pre-buffer the video. Any suggestions?
Use
[MPMoviePlayerControllerInstance prepareToPlay]
as soon as you know that the user
might start playback of a movie. You
might also want set
MPMoviePlayeController.autoPlay to
something that fits best, depending
on your application.
From Apple's Documentation;
This method is called
automatically when you call the play
method. Calling it before you call
play gives the receiver a chance to
prepare items sooner and may result in
decreased latency when starting
playback. However, calling this method
may also interrupt any active audio
sessions.
Make sure your HTTP stream contains
a low bandwidth alternative using
less than 64Kbps (audio and video combined). Note that the
MPMoviePlayerController usually
starts buffering the low rate
playback index profile before
raising the bar and attempting to
load higher bandwidth profiles. It
will be prepared to play once it has
a few seconds worth of movie data.
Use the
MPMoviePlayerController.movieSourceType
property when initializing your
player to cut down the media
recognition delay.
From the MPMoviePlayerController
Class Reference:
The default value of this property is
MPMovieSourceTypeUnknown. This
property provides a clue to the
playback system as to how it should
download and buffer the movie content.
If you know the source type of the
movie, setting the value of this
property before playback begins can
improve the load times for the movie
content. If you do not set the source
type explicitly before playback, the
movie player controller must gather
this information, which might delay
playback.

Resources