首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

win32如何判断是否播放完音乐

2012-09-08 
win32怎么判断是否播放完音乐MCIWndCreate()播放的音乐怎么用case MM_MCINOTIFY:判断是否播放完毕应该写在

win32怎么判断是否播放完音乐
MCIWndCreate()播放的音乐怎么用case MM_MCINOTIFY:判断是否播放完毕
应该写在回调函数哪一块?迷惑。

[解决办法]
在回调函数中解析消息MM_MCINOTIFY

MM_MCINOTIFY
The MM_MCINOTIFY message notifies an application that an MCI device has completed an operation. MCI devices send this message only when the MCI_NOTIFY flag is used.

MM_MCINOTIFY 
wParam = (WPARAM) wFlags 
lParam = (LONG) lDevID
 
Parameters
wFlags 
Reason for the notification. The following values are defined: 
MCI_NOTIFY_ABORTED 
The device received a command that prevented the current conditions for initiating the callback function from being met. If a new command interrupts the current command and it also requests notification, the device sends this message only and not MCI_NOTIFY_SUPERSEDED. 
MCI_NOTIFY_FAILURE 
A device error occurred while the device was executing the command. 
MCI_NOTIFY_SUCCESSFUL 
The conditions initiating the callback function have been met. 
MCI_NOTIFY_SUPERSEDED 
The device received another command with the "notify" flag set and the current conditions for initiating the callback function have been superseded. 
lDevID 
Identifier of the device initiating the callback function. 
Return Values
Returns zero if successful or an error otherwise.

Remarks
For more information about the MCI_NOTIFY flag, see The Notify Flag.

A device returns the MCI_NOTIFY_SUCCESSFUL flag with MM_MCINOTIFY when the action for a command finishes. For example, a CD audio device uses this flag for notification for the play (MCI_PLAY) command when the device finishes playing. The play command is successful only when it reaches the specified end position or reaches the end of the media. Similarly, the seek (MCI_SEEK) and record (MCI_RECORD) commands do not return MCI_NOTIFY_SUCCESSFUL until they reach the specified end position or reach the end of the media.

A device returns the MCI_NOTIFY_ABORTED flag with MM_MCINOTIFY only when it receives a command that prevents it from meeting the notification conditions. For example, the play command would not abort notification for a previous play command provided that the new command does not change the play direction or change the ending position. The seek and record commands behave similarly. MCI also does not send MCI_NOTIFY_ABORTED when playback or recording is paused with the pause (MCI_PAUSE) command. Sending the resume (MCI_RESUME) command allows them to continue to meet the callback conditions. 

When your application requests notification for a command, check the error return of the mciSendString or mciSendCommand functions. If these functions encounter an error and return a nonzero value, MCI will not set notification for the command.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in mmsystem.h.

See Also
MCI Overview, MCI Messages, MCI_PAUSE, MCI_PLAY, MCI_RECORD, MCI_RESUME, MCI_SEEK, mciSendString, mciSendCommand, pause, play, record, resume, seek

 

热点排行