Search code examples
objective-cplayback

Objective-C :: Play music by sentence


I am making Shadowing application . I have in trouble that play music by sentence. like this ,...

If Music is given this "hello world. super world" , I want to do like this...

@implementation
....
MPMusicPlayerController *musicPlayer;

- (void) playMusicByOneSentence
{
            //[musicPlayer play] is play a whole song. I want to play song by each sentence and sleep 5 sec.

            //[musicPlayer play];
            // I want to like following like this
            [musicPlayer playByOneSentence];
    }
}

playByOneSentenc method is continue play sound one sentence, and stop 5 sec until finished a whole song.

But I have no idea like above this action. Objective-C's play method is just play a whole music.

Do you have any idea?


Solution

  • One way to handle this would be to slice your music into separate files and then play each of them separately.

    If you give a logical naming scheme to the files (e.g. sound1.mp3, sound2.mp3,..., sound42.mp3) you can easily loop through the files and play them as needed or store the information on file names and pauses in a plist to be loaded into a dictionary at runtime.