Playing Video in a Dialog

Fernand Vanrie sos at pmgroup.be
Thu Apr 17 02:23:19 PDT 2014


On The French user site i found usefull code to play video on Windows 
using the API and Basic.

The code opens a MediaWindow and play any video

The player has a undocumented method "CreatePlayerWindow" who needs 
arguments (a empty array do crash LO)

Do someone knows how to use this method and how Video can been played in 
a Dialog ?

Thanks for any hints

Global video
Global oPlayer
Global Player_flag, Video_flag, Time

' ----------------------------------------------------------------------
Sub VideoPlayer
    If Video_flag = 0 Then
      video =converttoURL("C:\Users\PMG\Videos\Untitled.avi") ' La vidéo 
à charger
      Video_flag = 1
'for windows:
      oManager = CreateUnoService("com.sun.star.media.Manager_DirectX")
' for Linux
'             oManager = 
CreateUnoService("com.sun.star.media.Manager_GStreamer")
         End Select
      oPlayer = oManager.createPlayer( video )
    '  oPlayer.CreatePlayerwindow(array()) ' do crash LO
      oPlayer.start() ' Lecture
      Player_flag = 1
    Else
      oPlayer.start() ' Lecture
      Player_flag = 1
    End If
End Sub

' ----------------------------------------------------------------------
Sub VideoPlayer_pause
    If Player_flag = 1 Then
     oPlayer.stop() ' Pause
     Player_flag = 0
     Time = oPlayer.getmediatime()
    End If
End Sub

' ----------------------------------------------------------------------
Sub VideoPlayer_avance_rapide
    If Player_flag = 0 Then
     oPlayer.setmediatime(Time +1) ' Avance_rapide
     Time = oPlayer.getmediatime()
    End If
End Sub

' ----------------------------------------------------------------------
Sub VideoPlayer_recul_rapide
    If Player_flag = 0 Then
     oPlayer.setmediatime(Time -1) ' Recul_rapide
     Time = oPlayer.getmediatime()
    End If
End Sub

' ----------------------------------------------------------------------
Sub VideoPlayer_stop
    oPlayer.stop() ' Pause
    'Video_flag = 1
    Time = 0
    oPlayer.setmediatime(Time)
End Sub



More information about the LibreOffice mailing list