This is the code that I use for looping vdo play.
Code: Select all | Expand
DEFINE DIALOG oDlg SIZE nWndWidth, nWndHeight ;
STYLE nOr( WS_CHILD, WS_POPUP ) ;
COLOR CLR_BLACK, CLR_WHITE ;
FONT oFont60
DEFINE TIMER oDlgCLose INTERVAL 10000 ACTION iif(MEMVAR->lCloseAll, (MEMVAR->lGoHome := .T., oDlg:End()), )
DEFINE TIMER oTimer[1] INTERVAL 1500 ACTION (lOk := StartScan0(.T., MEMVAR->cImgPath+cTimeFile+'.JPG',.T., oTimer, oSay, oBmp), if(lOk, oDlg:End(), ))
DEFINE TIMER oTimer[2] INTERVAL 100 ACTION (if(oActiveX2:controls:currentPosition > oActiveX2:currentMedia:duration - 0.02, (oActiveX2:controls:currentPosition := 0.02), if(oActiveX2:controls:currentPosition > 0.01, oActiveX2:Show() , ) ))
ACTIVATE DIALOG oDlg CENTER ;
ON INIT (BuildMPlayer2( oDlg, MEMVAR->cGifPath+"idcard.Mp4", 110+MEMVAR->nTopDlg, 151+nPlus2, 720, 406 ), ;
oTimer[1]:Activate(), ;
oTimer[2]:Activate(), ;
oDlgCLose:Activate(), ;
AddGif( oDlg, MEMVAR->cGifPath+"wait.gif" ), oGif:Hide()) ;
ON PAINT (Drawlight(oDlg, nTitleBox, 140+nPlus2, 740, 72 ), ;
Drawlight(oDlg, 90+MEMVAR->nTopDlg, 131+nPlus2, 760, 446 )) ;
VALID (oTimer[2]:Deactivate(), oTimer[2]:End(), ;
oTimer[1]:Deactivate(), oTimer[1]:End(), ;
oDlgCLose:Deactivate(), oDlgCLose:End(), ;
oActiveX2:Url := nil, oActiveX2:Close(), ;
.T.)
*--------------------------------------------------------------------------*
function BuildMPlayer2( oDlg, cFile, nTop, nLeft, nWidth, nHeight )
Memory( -1 )
// oActiveX2 = TActiveX():New( oDlg, "{6BF52A52-394A-11d3-B153-00C04F79FAA6}", nTop, nLeft, nWidth, nHeight )
oActiveX2 = TActiveX():New( oDlg, "WMPlayer.OCX.7", nTop, nLeft, nWidth, nHeight )
// oActiveX2 = TActiveX():New( oDlg, "WMPlayer.OCX", nTop, nLeft, nWidth, nHeight )
oActiveX2:Hide()
oActiveX2:url = cFile
oActiveX2:uiMode('none')
oActiveX2:Settings:Volume = 0
oActiveX2:Settings:AutoStart = .T.
oActiveX2:StretchToFit = .T.
oActiveX2:EnableContextMenu()
oActiveX2:Settings:setMode("loop",.T.)
return nil
Jimmy wrote:hi Dutch,
you can use
CLSID
or PROGID
i wonder that it is working with "WMPlayer.OCX" without ".7"
---
you need to "destroy" ActiveX
but only when not used any more
---
does assign "new" Media but here it is empty
---
i have to search in my Xbase++ / harbour Code how i "loop" but i "think" i don`t use it this Way
your Code does not use "Timeline" so you don`t have "CurrentPosition()" to identify "End of File"
i recommend to use a TIMER to get Property when "IsPlaying()"
at EOF (IF nPosi >= nDuration - 1) i "reset" Position and play it again
here some Code from my harbour Project, have a look a "nDuration"
Note : i use a own "Scrollbar" which can be used with Mouse-Wheel to find "quick" a Position
Code: Select all | Expand
nPlayState := o__WMP:PlayState()
DO CASE
CASE o__WMP:IsPlaying()
// show moving Slider when playing
DoMethod( "Form_1", "Setfocus" )
DoMethod( "Form_1", "oScroll", "Setfocus" )
nPosi := o__WMP:CurrentPosition()
cPosi := SEC2HMS( nPosi )
SbarText( cPosi, 2 )
nDuration := o__WMP:Duration()
IF !EMPTY( nDuration )
nScroll := nPosi
SetProperty( "Form_1", "oScroll", "VALUE", nScroll )
IF nPosi >= nDuration - 1
lFullScr := o__WMP:fullScreen()
SetProperty( "Form_1", "oScroll", "VALUE", 1 )
o__WMP:Stop()
ShowHideWMP( "HIDE" )
IF SP_Loop() = .T.
o__WMP:CurrentPosition( 1 )
o__WMP:Play()
ELSEIF SP_Endless()
// Play_Next()
SENDKEY( VK_NEXT )
ENDIF
ENDIF
ENDIF
CASE nPlayState = wmppsUndefined
CASE nPlayState = wmppsStopped
cPosi := SEC2HMS( 0 )
SbarText( cPosi, 2 )
DoMethod( "Form_1", "Setfocus" )
SetProperty( "Form_1", "oScroll", "VALUE", 1 )
CASE nPlayState = wmppsPaused
xKey := HMG_GetLastVirtualKeyDown()
IF xKey = VK_RETURN
PauseOrPlay()
ENDIF
CASE nPlayState = wmppsScanForward
CASE nPlayState = wmppsScanReverse
CASE nPlayState = wmppsBuffering
SbarText( "Buffering ..." )
CASE nPlayState = wmppsWaiting
CASE nPlayState = wmppsMediaEnded
CASE nPlayState = wmppsTransitioning // this event is after open Media
SbarText( "Transitioning ..." )
CASE nPlayState = wmppsReady
CASE nPlayState = wmppsReconnecting
CASE nPlayState = wmppsLast
ENDCASE
p.s.
i do use a Listbox as "Playlist" and not WMP-Playlist