如何使用图像IOS的NSMutableArray创建带有mp3的视频

时间:2014-08-20 12:19:52

标签: ios objective-c ios7

我想使用图像的NSMutableArray创建一个带mp3的视频。我有多个图像阵列,我想用自定义mp3文件(用户选择的mp3)创建一个视频。

2 个答案:

答案 0 :(得分:0)

使用Simple Animation Using UIImageView并使用AVAudioPlayer播放选定的mp3文件作为背景音乐。

 //Animation
 // Load images
    NSArray *imageNames = @[@"win_1.png", @"win_2.png", @"win_3.png", @"win_4.png",
                        @"win_5.png", @"win_6.png", @"win_7.png", @"win_8.png",
                        @"win_9.png", @"win_10.png", @"win_11.png", @"win_12.png",
                        @"win_13.png", @"win_14.png", @"win_15.png", @"win_16.png"];

    NSMutableArray *images = [[NSMutableArray alloc] init];
    for (int i = 0; i < imageNames.count; i++) {
        [images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
    }

    // Normal Animation
    UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 95, 86, 193)];
    animationImageView.animationImages = images;
    animationImageView.animationDuration = 0.5;

    [self.view addSubview:animationImageView];
    [animationImageView startAnimating];

//background music
 //start a background sound
    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"Soothing_Music2_Long" ofType: @"mp3"];
    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath ];    
    myAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
    myAudioPlayer.numberOfLoops = -1; //infinite loop
    [myAudioPlayer play];

答案 1 :(得分:0)

我认为此链接对您有用.. GitHub Link