#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface RootViewController : UIViewController
<AVAudioPlayerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
{
UIImageView * backImageView;
AVAudioPlayer *_audioPlayer;
NSMutableArray *musicArray;
NSMutableArray *titleArray;
int songIndex;
UIButton * leftButton;
UIButton * rightButton;
UILabel *titleLabel;
UISlider *Slider;
UISlider *volumeSlider;
NSTimer * processTimer;
NSTimer * timer1;
}
@end
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"故事";
//初始化数据
[self initData];
//初始化背景图
[self initBackgroundView];
}
#pragma -mark -functions
//初始化数据
-(void)initData
{
musicArray=[[NSMutableArray alloc]initWithObjects:@"7",@"11",@"9",@"17",@"5",@"6",@"1",@"8",@"15",@"10",@"2",@"12",@"13",@"14",@"4",@"16",@"3",@"18", nil];
titleArray=[[NSMutableArray alloc]initWithObjects:@"三头公牛和狮子",@"小红帽",@"天女散花",@"朋友再见",@"女娲造人",@"天神的哑水",@"小青蛙听故事",@"淘淘的愿望",@"讲礼貌",@"丑小鸭",@"老鼠,小鸟和香肠",@"两头驴子",@"驴子和主人",@"四个朋友",@"奖品",@"没法通过",@"五颗豌豆",@"彼得*潘", nil];
}
//初始化背景图
-(void)initBackgroundView
{
self.navigationController.navigationBar.tintColor =[UIColor orangeColor];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:69.0/255 green:161.0/255 blue:241.0/255 alpha:1];
//背景
backImageView= [[UIImageView alloc] initWithFrame: CGRectMake(0, 0, 320, 460)];
backImageView.image= [UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg",[musicArray objectAtIndex:songIndex]]];
[self.view addSubview:backImageView];
//播放
UIButton* button= [UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(130, 260, 60, 50);
button.tag=100;
[button addTarget:self action:@selector(play:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
[self.view addSubview:button];
//上一首
leftButton= [UIButton buttonWithType:UIButtonTypeCustom];
leftButton.frame=CGRectMake(50, 260, 60, 50);
[leftButton addTarget:self action:@selector(prier) forControlEvents:UIControlEventTouchUpInside];
[leftButton setImage:[UIImage imageNamed:@"left.png"] forState:UIControlStateNormal];
[self.view addSubview:leftButton];
//下一首
rightButton= [UIButton buttonWithType:UIButtonTypeCustom];
rightButton.frame=CGRectMake(210, 260, 60, 50);
[rightButton addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUp