这个播放器的源码有误,请教如何修改
网上看到的Windows Media Player udf,运行出错,大概是函数重复定义,请教大家如何修改。#include <GUIConstants.au3>
#include <wmp.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("AForm1", 518, 439, 192, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
$wmp = _wmpcreate(1, 8, 8, 425, 425);creates object
_wmpvalue( $wmp, "nocontrols" );hides controls
_wmploadmedia( $wmp, @HomeDrive & "\WINDOWS\clock.avi" );loads media
;_wmpsetvalue( $wmp, "controls" );shows controls
$slider = GUICtrlCreateSlider( 4, 330, 330, 25 )
GUICtrlSetOnEvent( -1, "change" )
GUISetState(@SW_SHOW)
While _wmpvalue($wmp,"getduration") = 0
Sleep(1)
WEnd
GUICtrlSetLimit($slider,_wmpvalue($wmp,"getduration"),0)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
GUICtrlSetData( $slider, _wmpvalue($wmp,"getposition"))
WEnd
Func quit()
Exit
EndFunc
Func change()
_wmpvalue($wmp,"setposition",GUICtrlRead($slider))
EndFunc
#cs
_wmpcreate($show, $left, $top, $width = 100, $height = 100)
$show: 1 = shows controls
2 = hides controls
Return: The object for the control
#ce
Func _wmpcreate($show, $left, $top, $width = 100, $height = 100)
$oWMP = ObjCreate("WMPlayer.OCX")
If $oWMP = 0 Then Return 0
$oWMP.settings.autoStart = "False"
If $show = 1 Then
GUICtrlCreateObj($oWMP, $left, $top, $width, $height)
EndIf
Return $oWMP
EndFunc
#cs
_wmploadmedia( $object, $URL, $autostart = 1 )
$object: Object returned from the _wmpcreate()
$URL: Path or URL of the media
$autostart: 1 = yes
0 = no
Return: None
#ce
Func _wmploadmedia( $object, $URL, $autostart = 1 )
$object.URL = $URL
While Not $object.controls.isAvailable("play")
Sleep(1)
WEnd
If $autostart = 1 Then $object.controls.play()
EndFunc
#cs
_wmpsetvalue( $object, $setting, $para=1 )
$object: Object returned from the _wmpcreate()
$setting: "play"
"stop"
"pause"
"invisible" (Hides all)
"control" (Shows controls)
"nocontrol" (Hides controls)
"fullscreen"
"step" (frames to step before freezing)
"fastforward"
"fastreverse"
"volume" (0 To 100)
"rate" (-10 To 10)
"playcount"
Return: None
#ce
Func _wmpvalue( $object, $setting, $para=1 )
Select
Case $setting = "play"
If $object.controls.isAvailable("play") Then $object.controls.play()
Case $setting = "stop"
If $object.controls.isAvailable("stop") Then $object.controls.stop()
Case $setting = "pause"
If $object.controls.isAvailable("pause") Then $object.controls.pause()
Case $setting = "invisible"
$object.uiMode = "invisible"
Case $setting = "controls"
$object.uiMode = "mini"
Case $setting = "nocontrols"
$object.uiMode = "none"
Case $setting = "fullscreen"
$object.fullscreen = "true"
Case $setting = "step"
If $object.controls.isAvailable("step") Then $object.controls.step($para)
Case $setting = "fastForward"
If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward()
Case $setting = "fastReverse"
If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse()
Case $setting = "volume"
$object.settings.volume = $para
Case $setting = "rate"
$object.settings.rate = $para
Case $setting = "playcount"
$object.settings.playCount = $para
Case $setting = "setposition"
$object.controls.currentPosition = $para
Case $setting = "getposition"
Return $object.controls.currentPosition
Case $setting = "getpositionstring";Returns HH:MM:SS
Return $object.controls.currentPositionString
Case $setting = "getduration"
Return $object.currentMedia.duration
EndSelect
EndFunc
[ 本帖最后由 hlzxcjx 于 2008-8-3 20:52 编辑 ] 定义重复你就换个名字吗,不能让他“恶”你是不是? #include <GUIConstants.au3>
#include <wmp.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("播放器", 518, 439, 192, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
$wmp = _wmpcreate(1, 8, 8, 425, 425);creates object
_wmpvalue( $wmp, "nocontrols" );hides controls
_wmploadmedia( $wmp, @HomeDrive & "\WINDOWS\clock.avi" );loads media
;_wmpsetvalue( $wmp, "controls" );shows controls
$slider = GUICtrlCreateSlider( 4, 330, 330, 25 )
GUICtrlSetOnEvent( -1, "change" )
GUISetState(@SW_SHOW)
While _wmpvalue($wmp,"getduration") = 0
Sleep(1)
WEnd
GUICtrlSetLimit($slider,_wmpvalue($wmp,"getduration"),0)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
GUICtrlSetData( $slider, _wmpvalue($wmp,"getposition"))
WEnd
Func quit()
Exit
EndFunc
Func change()
_wmpvalue($wmp,"setposition",GUICtrlRead($slider))
EndFunc
#cs
_wmpcreate($show, $left, $top, $width = 100, $height = 100)
$show: 1 = shows controls
2 = hides controls
Return: The object for the control
#ce
Func _wmpcreate1($show, $left, $top, $width = 100, $height = 100)
$oWMP = ObjCreate("WMPlayer.OCX")
If $oWMP = 0 Then Return 0
$oWMP.settings.autoStart = "False"
If $show = 1 Then
GUICtrlCreateObj($oWMP, $left, $top, $width, $height)
EndIf
Return $oWMP
EndFunc
#cs
_wmploadmedia( $object, $URL, $autostart = 1 )
$object: Object returned from the _wmpcreate()
$URL: Path or URL of the media
$autostart: 1 = yes
0 = no
Return: None
#ce
Func _wmploadmedia1( $object, $URL, $autostart = 1 )
$object.URL = $URL
While Not $object.controls.isAvailable("play")
Sleep(1)
WEnd
If $autostart = 1 Then $object.controls.play()
EndFunc
#cs
_wmpsetvalue( $object, $setting, $para=1 )
$object: Object returned from the _wmpcreate()
$setting: "play"
"stop"
"pause"
"invisible" (Hides all)
"control" (Shows controls)
"nocontrol" (Hides controls)
"fullscreen"
"step" (frames to step before freezing)
"fastforward"
"fastreverse"
"volume" (0 To 100)
"rate" (-10 To 10)
"playcount"
Return: None
#ce
Func _wmpvalue( $object, $setting, $para=1 )
Select
Case $setting = "play"
If $object.controls.isAvailable("play") Then $object.controls.play()
Case $setting = "stop"
If $object.controls.isAvailable("stop") Then $object.controls.stop()
Case $setting = "pause"
If $object.controls.isAvailable("pause") Then $object.controls.pause()
Case $setting = "invisible"
$object.uiMode = "invisible"
Case $setting = "controls"
$object.uiMode = "mini"
Case $setting = "nocontrols"
$object.uiMode = "none"
Case $setting = "fullscreen"
$object.fullscreen = "true"
Case $setting = "step"
If $object.controls.isAvailable("step") Then $object.controls.step($para)
Case $setting = "fastForward"
If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward()
Case $setting = "fastReverse"
If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse()
Case $setting = "volume"
$object.settings.volume = $para
Case $setting = "rate"
$object.settings.rate = $para
Case $setting = "playcount"
$object.settings.playCount = $para
Case $setting = "setposition"
$object.controls.currentPosition = $para
Case $setting = "getposition"
Return $object.controls.currentPosition
Case $setting = "getpositionstring";Returns HH:MM:SS
Return $object.controls.currentPositionString
Case $setting = "getduration"
Return $object.currentMedia.duration
EndSelect
EndFunc 谢谢各位!
页:
[1]