跳转至

AudioStop 停止音效

格式

AudioStop(soundId)

简介

停止播放声音。

参数

名称 类型 描述
soundId int 声音对应ID

实例

运行开始时播放声音,按下鼠标左键停止播放声音sound。

import fg
import wx

asset = fg.AssetCreate()
asset.name = 'Main Scene'
asset.state = fg.STATE.VOXMODEL
asset.vmFile = 'mainScene'
asset.icon='icon.png'

fg.AssetRegister(asset)

def onStart(self):
    global sound
    sound=wx.AudioCreate("BGM.mp3",True)
    wx.AudioPlay(sound, True)

def onmouse(self, stamp, button, action, mods):
    global sound
    if button==wx.MOUSE_BUTTON.LEFT and action==wx.ACTION.PRESS:
        wx.AudioStop(sound)

fg.AssetSetStartCBFunc(asset, onStart)
fg.AssetSetMouseButtonCBFunc(asset, onmouse)