< a > The core function of QQ music is Play the song .
Play the audio, first think can use avfoundation frame, to complete the main function of playing music. But Avfoundation can only play local music and not play it online. Although you can download the resources from the network to the local re-play, but must be the whole song to download the complete before playing, so the effect is not good.
!
If you want to play online, you can choose the Audio Queue service in the Audiotoolbox framework. The Audio queue service can complete audio recording and playback.
A. Frequency service queue The audio queue has three components:
Three buffers buffers: each buffer is a temporary warehouse where audio data is stored.
A buffer queue: An ordered queue that contains an audio buffer.
A callback callback: a custom queue callback function.
The process of audio playback:
The audio is read into the buffer, once a buffer is filled and then placed in the buffer queue, and then continue to populate the other buffers, when the playback starts, the first buffer to read the audio playback, once played, the callback function will be triggered to start playing the next buffer audio, Fills the first buffer at the same time, fills it up and then puts it back into the buffer queue again.
Streaming media
All right? Music player to ensure the smooth playback, must be side loading side play, if done better, you can use streaming media to do.
Detailed content ...
< two > get the song list, show it in the field?
this part mainly through the AFN to get the song information from the network, and then display on the interface. For the interface show this part is more familiar, do not make it difficult. continue to add
< three > song download to local storage
Song offline download management This part is also very important. The song name, author and other related information can be stored in the database, the song's source files and lyrics files, downloaded and saved to the folder specified in the sandbox.
< four > Other features such as other settings are similar to other software.
Can be compared to QQ player, pick their own familiar places detailed explanation of how to achieve.
Analysis of Music app (example: QQ music)