I have a MP3 file on my server that is 30 seconds long. I only want to play the first 5 seconds as a "preview".
Currently I am loading the full MP3 and then playing the file through AVAudioPlayer for the first 5 seconds. The issue I have with this is if the user is not on a WiFi network, this eventually can become expensive in terms of the user's data plan. I thought of finding a way to cut off downloading of the file after x amount (which I would have to calculate) of data is sent but not sure if this would be the right solution.
Any suggestions are appreciated.
If you want to stream audio, try AVPlayer.
You can use NStimer:
When you start streaming just fire timer and in
stopAudio
method stop streaming audio afternumberOfSeconds
seconds.