In Chapter 1, Graphics, we used the MPMoviePlayerController
class
to play full motion video. In this recipe, we will use a similar technique to create a streaming audio player.
Link the MediaPlayer
framework
to your project. Now, execute the following code:
#import <MediaPlayer/MediaPlayer.h> #import "AppDelegate.h" @implementation Ch6_StreamingAudio -(CCLayer*) runRecipe { //Create music player buttons [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"music_player.plist"]; CCMenuItemSprite *prevItem = [self menuItemFromSpriteFile:@"music_player_prev.png" target:self selector:@selector(previousSong:)]; /* CODE OMITTED */ //Create menu /* CODE OMITTED */ //Initial variable values sourceIndex = 0; isPlaying = NO; //Streaming sources streamingSources = [[NSMutableArray alloc] init]; [streamingSources addObject...