开发者

How to Play Multiple Audio Files?

Though the question sounds basic and really simple to answer - but I have not found a complete answer either in any book/Forum/website.

Quick Background of My App:

I have a Dependent/Multiple UI Picker (2 UI Pickers - Lets call them P1 and P2), UITEXTVIEW and bar at bottom of the screen. in the bar I have buttons like "Play" ""Pause", "Rewind" and "Forward", every time I s开发者_JS百科croll the UIpicker P1 the value of the Picker p2 changes and accordingly the text in UITextView.

I have to embed 700 mp3 files in my application (dont be surprised about the idea of putting so many files in an app - total size of all mp3's is 49 mp, these are each 20 second file and at very low bitrate). I want to play each mp3 file with respect to the value in the Pickers.

here is the flow - > I scroll P1 -> Value in P1 Changes -> value of P2 changes -> text in TextView changes.

Its like "Chapters" in P1 and Paragraph number in P2, and actual text of paragraph in TextView.

after this I want to embed mp3 files so that so that with the respective canges in the pickers (P1 and P2) the mp3 in the "play" "pause" "Rewind" and "Forward" should also change.

My Requirement is as follows:

on changing the picker value the the mp3 file refered in the "play" button should change accordingly.

My Idea towards my requirement:

  1. For playing the mp3 files I have to put them in resources folder and refer them using NSBundle
  2. I might have to make NSDictionary Array for referring the names of the mp3 files
  3. I might have to create a method (checking the mp3 files based upon the values of pickers) that would be placed in rowdidselect section of UIPicker.

Guys - Please help me on this. your ideas, comments, Answers and suggestions all would be helpful.

Please contribute :-)

Thanks in advance :-)


I'd say you have a reasonable approach pretty much figured out. There's more than one way to accomplish this goal but yours is reasonable. Why not try it?

I'd just suggest one AVPlayer and load one clip at a time. Don't keep any loaded clips around after a new clip is loaded. Since you appear only to need to play one file at a time, one player will do and will release the memory as you give it a new clip to play. Since you referenced iOS and your files are small, loading them should be plenty efficient.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜