幻灯片效果+背景音乐

来源:互联网 发布:知乎福利大合集 编辑:程序博客网 时间:2024/05/16 10:27
 Iphone幻灯片效果+背景音乐
今天弄了几张好看的图片,我就摸索着实现了图片的幻灯片效果,这个以前也实现过了,也算是温故知新吧,另外就是使用SoundEngine类实现背景音乐的播放。SoundEngine类可以从[url=read.php?tid-1215.html]http://www.cocoachina.com/bbs/read.php?tid-1215.html[/url]下载到。

代码很简单贴出来,以备不时只需:
-(void)viewDidLoad
{
 
array = [[NSMutableArray alloc] init];
 
int i = 1;
 
for(i;i<=30;i++)
 
{
 
[array addObject:[UIImageimageNamed:[NSString stringWithFormat:@"%d.jpg",i]]];
 
}
 
pictures.animationImages = array;
 
pictures.animationDuration = 300;//时间间隔
 
pictures.animationRepeatCount = 0;//循环播放
 
[pictures startAnimating];//开始播放



//播放背景音乐,利用SoundEngine类进行播放
 
SoundEngine_SetListenerPosition(0.0, 0.0,1.0);
 
SoundEngine_Initialize(44100);
 
SoundEngine_LoadBackgroundMusicTrack([[[NSBundlemainBundle] pathForResource:@"win" ofType:@"caf"] UTF8String],true, true);
 
SoundEngine_StartBackgroundMusic();
}


用这种方法播放好像挺占用资源的,比较卡,以后再研究研究其它的方法。
原创粉丝点击