0

我正在使用以下代码:my Sound is placed in myapp/Shared Resources/background_music.aiff

@synthesize window = _window;
- (void)dealloc
{
    [backgroundSound release];
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    sleep(3);
     //this variable can be named differently

    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/background_music.aiff",[[NSBundle mainBundle] resourcePath]]];
    NSError *error;

    backgroundSound = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];

     backgroundSound.numberOfLoops = -1;
    //>> this will allow the file to //play an infinite number of times */

    return YES;
}



@interface AppDelegate : UIResponder <UIApplicationDelegate>{
    AVAudioPlayer *backgroundSound;

}

@property (strong, nonatomic) UIWindow *window;
@end

没有错误,也没有循环声音。请告诉我发生了什么。

最好的祝福

4

2 回答 2

2

好的,我添加了[background play];,它已经开始正常工作了.....我正在关注的教程中没有提到..

于 2012-08-27T14:20:30.830 回答
0
 player = [[MPMoviePlayerController alloc] initWithContentURL:url];
    player.movieSourceType = MPMovieSourceTypeStreaming;
    if(player.playbackState == MPMoviePlaybackStatePlaying)
        [player stop];
    [player play];
于 2012-08-27T13:23:51.083 回答