home *** CD-ROM | disk | FTP | other *** search
/ ftp.alaska-software.com / 2014.06.ftp.alaska-software.com.tar / ftp.alaska-software.com / acsn / History / BDVIDEO / BDVIDEO.ZIP / DEMO.PRG < prev    next >
Text File  |  2002-08-20  |  8KB  |  233 lines

  1. #include "Gra.ch"
  2. #include "Xbp.ch"
  3. #include "Appevent.ch"
  4. #include "Font.ch"
  5.  
  6. #pragma library( "xppui2.lib" )
  7.  
  8. PROCEDURE AppSys()
  9. RETURN
  10.  
  11. PROCEDURE Main
  12.    LOCAL nEvent, mp1, mp2, bBlock
  13.    LOCAL oDlg, oXbp, drawingArea, oVideo, oStatic1, oStatic2, oStatic3, oStatic4
  14.    LOCAL cFileName := "", oRestore
  15.  
  16.    oDlg := XbpDialog():new(SetAppWindow():setParent(),,{30,60}, {740,520})
  17.    oDlg:taskList := .T.
  18.    oDlg:title    := "Demo for BDVideo Class - 2001 Brent Dubs"
  19.    oDlg:visible  := .T.
  20.    oDlg:close    := {|mp1,mp2,obj| obj:destroy(),_quit() }
  21.    oDlg:create()
  22.  
  23.    SetAppWindow( oDlg )
  24.  
  25.    drawingArea := oDlg:drawingArea
  26.    drawingArea:setFontCompoundName( "8.Arial" )
  27.  
  28.    oVideo := BDVideo():new(drawingArea,,{170,175},{400,300}):create()
  29.  
  30.    oStatic1 := XbpStatic():new(drawingArea,,{280,160},{350,15})
  31.    oStatic1:create()
  32.  
  33.    oStatic2 := XbpStatic():new(drawingArea,,{280,145},{350,15})
  34.    oStatic2:create()
  35.  
  36.    oStatic3 := XbpStatic():new(drawingArea,,{280,130},{350,15})
  37.    oStatic3:create()
  38.  
  39.    oStatic4 := XbpStatic():new(drawingArea,,{100,570},{350,20})
  40.    oStatic4:visible := .F.
  41.    oStatic4:caption := "Demo for BDVideo Class - 2001 Brent Dubs"
  42.    oStatic4:setColorFG(GRA_CLR_DARKBLUE)
  43.    oStatic4:setFontCompoundName("12.Arial")
  44.    oStatic4:create()
  45.  
  46.    oXbp := XbpPushButton():new( drawingArea, , {10,10}, {80,30} )
  47.    oXbp:caption := "Open"
  48.    oXbp:clipSiblings := .T.
  49.    oXbp:tabStop      := .T.
  50.    oXbp:create()
  51.    oXbp:activate := {|| cFilename := SelectFile("*.mpg;*.avi;*.dat"),;
  52.                         IF(ValType(cFileName) == "C" .AND. ;
  53.                         !EMPTY(cFileName),oVideo:loadFile(cFileName),cFileName := ""),;
  54.                         oStatic1:setcaption("FileName: " + AllTrim(oVideo:filename)),;
  55.                         oStatic2:setCaption("Length in seconds: " + Alltrim(STR(oVideo:length/1000))),;
  56.                         oStatic3:setCaption("Length in frames: " + Alltrim(STR(oVideo:frames)))}
  57.  
  58.    oXbp := XbpPushButton():new( drawingArea, , {100,10}, {80,30} )
  59.    oXbp:caption := "Play"
  60.    oXbp:clipSiblings := .T.
  61.    oXbp:tabStop      := .T.
  62.    oXbp:create()
  63.    oXbp:activate := {||IF(oVideo:paused,oVideo:play(),oVideo:play(.T.))}
  64.  
  65.    oXbp := XbpPushButton():new( drawingArea, , {190,10}, {80,30} )
  66.    oXbp:caption := "Stop"
  67.    oXbp:clipSiblings := .T.
  68.    oXbp:tabStop      := .T.
  69.    oXbp:create()
  70.    oXbp:activate := {||oVideo:stop()}
  71.  
  72.    oXbp := XbpPushButton():new( drawingArea, , {280,10}, {80,30} )
  73.    oXbp:caption := "Pause"
  74.    oXbp:clipSiblings := .T.
  75.    oXbp:tabStop      := .T.
  76.    oXbp:create()
  77.    oXbp:activate := {||oVideo:pause(.T.)}
  78.  
  79.    oXbp := XbpPushButton():new( drawingArea, , {370,10}, {80,30} )
  80.    oXbp:caption := "Play and Wait"
  81.    oXbp:clipSiblings := .T.
  82.    oXbp:tabStop      := .T.
  83.    oXbp:create()
  84.    oXbp:activate := {||oVideo:play(.T.,.T.)}
  85.  
  86.    oXbp := XbpPushButton():new( drawingArea, , {460,10}, {80,30} )
  87.    oXbp:caption := "Loop Video"
  88.    oXbp:clipSiblings := .T.
  89.    oXbp:tabStop      := .T.
  90.    oXbp:create()
  91.    oXbp:activate := {||oVideo:play(.T.,.F.,.T.)}
  92.  
  93.    oXbp := XbpPushButton():new( drawingArea, , {550,10}, {80,30} )
  94.    oXbp:caption := "Status"
  95.    oXbp:clipSiblings := .T.
  96.    oXbp:tabStop      := .T.
  97.    oXbp:create()
  98.    oXbp:activate := {||MSGBOX(oVideo:status(),"Playing mode status")}
  99.  
  100.    oXbp := XbpPushButton():new( drawingArea, , {640,10}, {80,30} )
  101.    oXbp:caption := "Close"
  102.    oXbp:clipSiblings := .T.
  103.    oXbp:tabStop      := .T.
  104.    oXbp:create()
  105.    oXbp:activate := {||oVideo:stop(),_quit()}
  106.  
  107.    oXbp := XbpPushButton():new( drawingArea, , {10,50}, {80,30} )
  108.    oXbp:caption := "Volume Up"
  109.    oXbp:clipSiblings := .T.
  110.    oXbp:tabStop      := .T.
  111.    oXbp:create()
  112.    oXbp:activate := {|| oVideo:setVolume(oVideo:volume+10)}
  113.  
  114.    oXbp := XbpPushButton():new( drawingArea, , {100,50}, {80,30} )
  115.    oXbp:caption := "Volume Down"
  116.    oXbp:clipSiblings := .T.
  117.    oXbp:tabStop      := .T.
  118.    oXbp:create()
  119.    oXbp:activate := {|| oVideo:setVolume(oVideo:volume-10) }
  120.  
  121.    oXbp := XbpPushButton():new( drawingArea, , {190,50}, {80,30} )
  122.    oXbp:caption := "Volume Status"
  123.    oXbp:clipSiblings := .T.
  124.    oXbp:tabStop      := .T.
  125.    oXbp:create()
  126.    oXbp:activate := {|| MSGBOX(ALLTRIM(STR(oVideo:volume))+"%","Volume level") }
  127.  
  128.    oXbp := XbpPushButton():new( drawingArea, , {280,50}, {80,30} )
  129.    oXbp:caption := "Mute"
  130.    oXbp:clipSiblings := .T.
  131.    oXbp:tabStop      := .T.
  132.    oXbp:create()
  133.    oXbp:activate := {|o| oVideo:mute(!oVideo:muted) }
  134.  
  135.    oXbp := XbpPushButton():new( drawingArea, , {370,50}, {80,30} )
  136.    oXbp:caption := "Frwd 5 Secs"
  137.    oXbp:clipSiblings := .T.
  138.    oXbp:tabStop      := .T.
  139.    oXbp:create()
  140.    oXbp:activate := {|| oVideo:seek((oVideo:getPosition()+5)) }
  141.  
  142.    oXbp := XbpPushButton():new( drawingArea, , {460,50}, {80,30} )
  143.    oXbp:caption := "Bkwd 5 Secs"
  144.    oXbp:clipSiblings := .T.
  145.    oXbp:tabStop      := .T.
  146.    oXbp:create()
  147.    oXbp:activate := {|| oVideo:seek((oVideo:getPosition()-5)) }
  148.  
  149.    oXbp := XbpPushButton():new( drawingArea, , {550,50}, {80,30} )
  150.    oXbp:caption := "Frwd 25 Frms"
  151.    oXbp:clipSiblings := .T.
  152.    oXbp:tabStop      := .T.
  153.    oXbp:create()
  154.    oXbp:activate := {|| oVideo:frameStep(25) }
  155.  
  156.    oXbp := XbpPushButton():new( drawingArea, , {640,50}, {80,30} )
  157.    oXbp:caption := "Bkwd 25 Frms"
  158.    oXbp:clipSiblings := .T.
  159.    oXbp:tabStop      := .T.
  160.    oXbp:create()
  161.    oXbp:activate := {|| oVideo:frameStep(-25) }
  162.  
  163.    oXbp := XbpPushButton():new( drawingArea, , {10,90}, {80,30} )
  164.    oXbp:caption := "Fast Forward"
  165.    oXbp:clipSiblings := .T.
  166.    oXbp:tabStop      := .T.
  167.    oXbp:create()
  168.    oXbp:activate := {|| IF(!(oVideo:status() == "playing"),oVideo:play(),NIL),;
  169.                         oVideo:setSpeed(200) }
  170.  
  171.    oXbp := XbpPushButton():new( drawingArea, , {100,90}, {80,30} )
  172.    oXbp:caption := "Slow"
  173.    oXbp:clipSiblings := .T.
  174.    oXbp:tabStop      := .T.
  175.    oXbp:create()
  176.    oXbp:activate := {|| IF(!(oVideo:status() == "playing"),oVideo:play(),NIL),;
  177.                         oVideo:setSpeed(50) }
  178.  
  179.    oXbp := XbpPushButton():new( drawingArea, , {190,90}, {80,30} )
  180.    oXbp:caption := "Normal Speed"
  181.    oXbp:clipSiblings := .T.
  182.    oXbp:tabStop      := .T.
  183.    oXbp:create()
  184.    oXbp:activate := {|| IF(!(oVideo:status() == "playing"),oVideo:play(),NIL),;
  185.                         oVideo:setSpeed(100) }
  186.  
  187.    oXbp := XbpPushButton():new( drawingArea, , {280,90}, {80,30} )
  188.    oXbp:caption := "MCI Ready?"
  189.    oXbp:clipSiblings := .T.
  190.    oXbp:tabStop      := .T.
  191.    oXbp:create()
  192.    oXbp:activate := {|| MSGBOX(IF(oVideo:ready(),"It's ready","Not Ready"),"MCI device ready status") }
  193.  
  194.    oXbp := XbpPushButton():new( drawingArea, , {640,90}, {80,30} )
  195.    oXbp:caption := "Full Screen"
  196.    oXbp:clipSiblings := .T.
  197.    oXbp:tabStop      := .T.
  198.    oXbp:create()
  199.    oXbp:activate := {|| oDlg:titleBar := .F., oDlg:configure(),;
  200.                         oDlg:setPosandSize({0,0},{800,600}),;
  201.                         oVideo:setPosandSize({0,0},{800,565}),;
  202.                         oRestore:show(), oStatic4:show(), SetAppFocus(oDlg) }
  203.  
  204.    oXbp := XbpPushButton():new( drawingArea, , {10,570}, {80,20} )
  205.    oXbp:caption := "Restore"
  206.    oXbp:clipSiblings := .T.
  207.    oXbp:tabStop      := .T.
  208.    oXbp:visible := .F.
  209.    oXbp:create()
  210.    oXbp:activate := {||oRestore:hide(),oStatic4:hide(),;
  211.                        oVideo:setPosandSize({170,175},{400,300}),;
  212.                        oDlg:titleBar := .T., oDlg:configure(),;
  213.                        oDlg:setPosandSize({30,60},{740,520}),;
  214.                        SetAppFocus(oDlg)}
  215.    oRestore := oXbp
  216.  
  217.  
  218.  
  219.    SetAppFocus(oDlg)
  220.  
  221.    DO WHILE .T.
  222.      nEvent := AppEvent( @mp1, @mp2, @oXbp, 0)
  223.      IF (bBlock := SetAppEvent(nEvent)) <> NIL
  224.        EVAL(bBlock,mp1,mp2,oXbp)
  225.      ELSE
  226.        oXbp:handleEvent( nEvent, mp1, mp2 )
  227.      ENDIF
  228.    ENDDO
  229.  
  230. RETURN
  231.  
  232. FUNCTION SelectFile(cFiles)
  233. RETURN XbpFileDialog():new():create( SetAppWindow() ):open(cFiles)