|
主题: 为什么背景音乐不循环?
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#12004/11/20 15:27:30
前辈们,我又遇到新问题了,我是让一首背景音乐在两个文件之间循环播放,音乐文件是放在根目录下的,并且把音乐放在音乐通道3中,我是这样写的: on startmovie sound playfile 3,the pathname & "BACK3-2.wav" end startmovie On enterframe if soundbusy (3) then nothing else sound playfile 3, the pathname & "BACK3-2.wav" end if end
可为什么不循环呢?
|
 我是小马
职务:普通成员
等级:3
金币:17.0
发贴:794
注册:2000/11/13 14:56:59
|
#22004/11/20 16:33:41
不应该放在On enterframe句柄下
在moviescript中加入如下代码: on idle if not soundbusy(3) then sound playfile 3, the pathname & "BACK3-2.wav" end if end
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#32004/11/26 17:13:40
版主还是不行
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#42004/11/26 17:15:41
我把这个“movie script” on idle if not soundbusy(3) then sound playfile 3, the pathname & "BACK3-2.wav" end if end 直接放在cast中就行了吗,不用拖到脚本通道中吗
|
 我是小马
职务:普通成员
等级:3
金币:17.0
发贴:794
注册:2000/11/13 14:56:59
|
#52004/11/26 17:21:24
script的type属性为Movie,不是Behaviors,也不是parent。
movie script不需要放到舞台上的。
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#62004/11/26 17:52:56
版主,问题解决了,我太感谢你们了,这个问题研究了整一天,我这手头就一本书,下次去北京一定请你们吃饭
|
 我是小马
职务:普通成员
等级:3
金币:17.0
发贴:794
注册:2000/11/13 14:56:59
|
#72004/11/26 23:26:52
[DirectorFAQ] 如何保持背景音乐连续 [2004-11-26]mazhiguo 发表在 DirectorFAQ-------------------------------------------------------------------------------- 要保持背景音乐连续,那我们就得频繁检测播放背景音乐的声音通道是否空闲,如果空闲就用sound(1).play(member (soundmember))来播放背景音乐。 这时我们就会想到Director中的on idle句柄,只要我们在每个影片的影片剧本中放置一个on idle句柄用来检测播放背景音乐,这样就可以实现背景音乐的连续了。 但是,也正是因为在on idle句柄中的语句会被频繁地运行,如果在on idle句柄中放置的处理语句比较多,会比较耗费系统资源。 如果要回避这个问题,我们换一种思路来考虑,背景音乐为什么会中断不连续呢?就是因为在每个影片中都有播放背景音乐的处理程序,在影片跳转的时候,播放背景音乐的行为都会重新执行,如果我们用一个单独的MIAW影片来播放背景音乐,就可以做到不管你的影片怎么跳转,背景音乐都可以不受干扰的播放,除非你关闭了播放背景音乐的MIAW 。 综上所述,我们至少有两种方法来解决这个问题: 解决方法一、使用on idle句柄。 然后新建一个影片剧本(script的type属性为movie),输入以下代码: on idle if not soundbusy(1) then --检测声音通道1,如果空闲执行以下语句 set i=random(8)-1 --给i随机赋值0~7 RandomMusic="music" & string(i) puppetSound 1,RandomMusic --随机播放背景音乐music0~music7 end if end 这样就可以实现背景音乐的连续播放了,而且是在music0~music7之间随机播放。 解决方法二、使用MIAW。 首先新建一个影片,命名为soundplay.dir,导入背景音乐文件,然后将演员名命名为music0~music7,然后在剪辑室(score)双击帧脚本通道,输入以下代码: on exitFrame me if not(soundBusy(1)) then soundmember = "music"& random(8)-1 --随机播放背景音乐 sound(1).play(member (soundmember)) end if go the frame end 此处与方法一相比,行为主体没有变化,只是其句柄不一样,此处是放在On exitFrame中。 然后新建一个影片,命名为main.dir,并新建一个影片剧本,输入以下代码: global miaw on preparemovie miaw = window("soundplay" --新建一个window,标题名为soundplay,保存在全局变量miaw中 miaw.filename = "soundplay" --子窗口的文件名为soundplay.dir miaw.visible = false --设置子窗口为不可见 end preparemovie 只要不forget window,背景音乐一直存在并且连续,但是要记住,在关闭背景音乐或者退出影片之前,要用miaw.forget()命令来关闭子窗口。
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#82004/11/27 17:52:42
版主,背景音乐问题解决了,又出现了一个问题,我设计了一个音乐控制按钮,(点下音乐关,点一下音乐又响),我把以下命令指给这个按钮: on mouseup me if soundBusy(3) then sound(3).stop() else sound playFile 3, "BACK3-2.wav" end if end mouseup 但是不起作用,何故,请指教,谢谢
|
 Super ChiCk
职务:版主
等级:5
金币:15.0
发贴:3502
注册:2003/9/6 14:53:41
|
#92004/11/27 19:11:02
文件路径的问题 sound playfile 3, (the movitpath)&"back3-2.wav"
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#102004/11/29 14:18:52
我是把音乐直接放在d的同级目录下的,我这样改了之后这样写还是不行? on mouseup me if soundBusy(3) then sound(3).stop() else sound playFile 3, "BACK3-2.wav" end if end mouseup 急煞我了
|
 Super ChiCk
职务:版主
等级:5
金币:15.0
发贴:3502
注册:2003/9/6 14:53:41
|
#112004/11/29 15:30:01
晕 sound playfile 3, (the movitpath)&"back3-2.wav"
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#122004/11/29 15:37:26
on mouseup me if soundBusy(3) then sound(3).stop() else sound playfile 3, (the movitpath)&"back3-2.wav" end if end mouseup 是这样吗,还是不行
|
 Super ChiCk
职务:版主
等级:5
金币:15.0
发贴:3502
注册:2003/9/6 14:53:41
|
#132004/11/29 15:45:27
不好意思 sound playfile 3, (the movitpath)&"back3-2.wav" 少写了个字母 sound playfile 3, (the moviepath)&"back3-2.wav"
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#142004/11/29 15:59:03
我这样改过了,还是不行哩
|
 apple
职务:普通成员
等级:1
金币:0.0
发贴:37
注册:2004/10/25 13:25:51
|
#152004/11/29 16:01:29
难道与我写的背景音乐有关(在movie script中) on startmovie sound playfile 3,the pathname & "BACK3-2.wav" end startmovie on idle if not soundbusy(3) then sound playfile 3, the pathname & "BACK3-2.wav" end if end
|