PureBasic
;
; ------------------------------------------------------------
;     PureBasic - Movie example file
;   
;     Взято где то в примерах.
;   
;     Автору Спасибо!
; ------------------------------------------------------------
;

Procedure MoviePos()
  If IsMovie(1)
    ;SetGadgetState(1, MovieInfo(1, 0))
    ;Debug  MovieInfo(1, 0)
  EndIf
EndProcedure


;InitSprite()
InitMovie()
OpenWindow(1,0,0,700,580,"Видео плеер", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible| #PB_Window_ScreenCentered)
SmartWindowRefresh(1, 1) 

ContainerGadget(0,0,0,700,520) : DisableGadget(0,1)
SetGadgetColor(0,#PB_Gadget_BackColor,0)
; OpenWindowedScreen(WindowID(1), 0, 0, 1, 1, 1, 0, 90)
CloseGadgetList()
TrackBarGadget(1, 10,  500, 680, 28, 0, 100)
ButtonGadget(2,10,550,110,24,"Открыть файл")
ButtonGadget(3,130,550,110,24,"Воспроизведение")
ButtonGadget(4,260,550,110,24,"Стоп")

TextGadget(5,400,530,80,24,"Громкость")
TrackBarGadget(6, 470,  528, 200, 22, 0, 100)
SetGadgetState(6,25)
TextGadget(7,400,554,80,24,"Баланс")
TrackBarGadget(8, 470,  552, 200, 22, 0, 200)
SetGadgetState(8,100)

HideWindow(1,0)

SetTimer_(WindowID(1), 1, 500, @MoviePos())

Repeat
  Event=WaitWindowEvent()
  
  If Event=#PB_Event_SizeWindow
    Width=WindowWidth(1)
    Height=WindowHeight(1)
    ResizeGadget(0,#PB_Ignore, #PB_Ignore,Width,Height-90) 
    ResizeGadget(1,#PB_Ignore, Height-80,Width-20,#PB_Ignore) 
    ResizeGadget(2,#PB_Ignore, Height-40,#PB_Ignore,#PB_Ignore)
    ResizeGadget(3,#PB_Ignore, Height-40,#PB_Ignore,#PB_Ignore)
    ResizeGadget(4,#PB_Ignore, Height-40,#PB_Ignore,#PB_Ignore)
    ResizeGadget(5,#PB_Ignore, Height-50,#PB_Ignore,#PB_Ignore)
    ResizeGadget(6,#PB_Ignore, Height-52,#PB_Ignore,#PB_Ignore)
    ResizeGadget(7,#PB_Ignore, Height-24,#PB_Ignore,#PB_Ignore)
    ResizeGadget(8,#PB_Ignore, Height-26,#PB_Ignore,#PB_Ignore)
    
    If IsMovie(1)
      ResizeMovie(1,0,0,GadgetWidth(0), GadgetHeight(0))
      UpdateWindow_(WindowID(1))
    EndIf
    
  ElseIf Event=#PB_Event_Gadget
    Gadget=EventGadget()
    Select Gadget
      Case 1
        If IsMovie(1)
          MovieSeek(1,GetGadgetState(1))
          ; Debug GetGadgetState(1)
        EndIf
      Case 2
        File.s=OpenFileRequester("","","Видео - (*.avi;*.mpg)|*.avi;*.mpg",1)
        If File<>"" 
          If LoadMovie(1, File)=0
            MessageRequester("", "Не удалось открыть файл", 64)
          EndIf
        EndIf
      Case 3
        If IsMovie(1)
          Select MovieStatus(1)
            Case -1
              ResumeMovie(1)
              SetGadgetText(3,"Воспроизведение")
            Case 0
              SetGadgetAttribute(1, #PB_TrackBar_Maximum, MovieLength(1)/MovieInfo(1,0))
              MovieAudio(1, GetGadgetState(6), GetGadgetState(8)-100)
              ResizeMovie(1,0,0,GadgetWidth(0), GadgetHeight(0))
              SetGadgetText(3,"Пауза")
              SetGadgetState(1,0)
              
              For i=1 To 100
                WindowEvent()
              Next i
              
              PlayMovie(1,GadgetID(0))
              
            Default 
              PauseMovie(1)
              SetGadgetText(3,"Воспроизведение")
          EndSelect
        EndIf
      Case 4
      Case 6, 8
        MovieAudio(1, GetGadgetState(6), GetGadgetState(8)-100)
    EndSelect
    
    
  EndIf
  
Until Event=#PB_Event_CloseWindow