当前位置: 代码迷 >> PB >> 播放wav文件,同步程序卡顿,异步不播放的有关问题
  详细解决方案

播放wav文件,同步程序卡顿,异步不播放的有关问题

热度:99   发布时间:2016-04-29 05:29:17.0
播放wav文件,同步程序卡顿,异步不播放的问题
使用api,sndPlaySoundA播放wav文件
参数
  0   -   同步播放   
  1   -   异步播放   
  2   -   如果找不到声音文件,不使用缺省的声音文件   
  3   -   第1项与第2项   
  8   -   循环播放直到下一个sndPlaysound   
  10-   不停止播放  
   返回值:   
  0   出错(通常是文件没有找到)   
  1   成功 

同步播放时,因为需要等待播放完毕,才能继续执行程序,所以出现卡顿的情况。
异步播放时,如果只执行一次函数,表现是很好的,程序能继续操作,声音也能播放
但是如果循环执行多次函数,就会出现不播放声音的问题

请问大家有没有方法,程序既能正常操作,声音也能正常播放?

百度的时候,发现有人咨询,将多个wav文件合并成一个文件,然后在播放的

------解决方案--------------------
可以考虑一下使用media player 控件
------解决方案--------------------
引用:
使用api,sndPlaySoundA播放wav文件
参数
  0   -   同步播放   
  1   -   异步播放   
  2   -   如果找不到声音文件,不使用缺省的声音文件   
  3   -   第1项与第2项   
  8   -   循环播放直到下一个sndPlaysound   
  10-   不停止播放  
   返回值:   
  0   出错(通常是文件没有找到)   
  1   成功 

同步播放时,因为需要等待播放完毕,才能继续执行程序,所以出现卡顿的情况。
异步播放时,如果只执行一次函数,表现是很好的,程序能继续操作,声音也能播放
但是如果循环执行多次函数,就会出现不播放声音的问题

请问大家有没有方法,程序既能正常操作,声音也能正常播放?

百度的时候,发现有人咨询,将多个wav文件合并成一个文件,然后在播放的


两种解决方案,如果用同步,肯定会有卡顿,建议控制一下,等播放完一个再播放下一个

如果用异步,你需要做的工作时不要一下子全调用,通过yield为控制一下,等播放结束后再调用下一个,就不会出现你说的问题了,否则肯定只播放最后一个,我以前用过
------解决方案--------------------
牛逼!!!!!!!!!!
------解决方案--------------------
Player Object
The Player object is the root object for the Windows Media Player control. It supports the properties, methods, and events listed in the following tables.
The Player object supports the following properties. Properties marked with an asterisk (*) are not accessible to skins.
Property Description
cdromCollection
Retrieves the CdromCollection object.

closedCaption
Retrieves the ClosedCaption object.

controls
Retrieves the Controls object.

currentMedia
Specifies or retrieves the current Media object.

currentPlaylist
Specifies or retrieves the current Playlist object.
dvd
Retrieves the DVD object.

enableContextMenu *
Specifies or retrieves a value indicating whether to enable the context menu, which appears when the right mouse button is clicked.
enabled *
Specifies or retrieves a value indicating whether the Windows Media Player control is enabled.
error
Retrieves the Error object.

fullScreen *
Specifies or retrieves a value indicating whether video content is played back in full-screen mode.
isOnline
Retrieves a value indicating whether the user is connected to a network.
isRemote *
Retrieves a value indicating whether the Windows Media Player control is running in remote mode.
mediaCollection
Retrieves the MediaCollection object.

network
Retrieves the Network object.

openState
Retrieves a value indicating the state of the content source.
playerApplication *
Retrieves the PlayerApplication object when a remoted Windows Media Player control is running.
playlistCollection
Retrieves the PlaylistCollection object.

playState
Retrieves a value indicating the state of the Windows Media Player operation.
settings
Retrieves the Settings object.

status
Retrieves a value indicating the current status of Windows Media Player.
stretchToFit *
Specifies or retrieves a value indicating whether video will stretch to fit size of the Windows Media Player control video display.
uiMode *
Specifies or retrieves a value indicating which controls are shown in the user interface when Windows Media Player is embedded in a Web page.
URL
Specifies or retrieves the name of the clip to play.
versionInfo
Retrieves a String value specifying the version of the Windows Media Player.
  相关解决方案