[Gambas-user] Fwd: [Gambas Bug Tracker] Bug #1154: MediaPipeline.position

Benoît Minisini gambas at ...1...
Mon Aug 28 19:09:31 CEST 2017



-------- Message transféré --------
Sujet : [Gambas Bug Tracker] Bug #1154: MediaPipeline.position
Date : Mon, 28 Aug 2017 17:04:39 GMT
De : bugtracker at ...3416...
Pour : joir2000 at ...67..., g4mba5 at ...626...

http://gambaswiki.org/bugtracker/edit?object=BUG.1154&from=L21haW4-

Comment #5 by Joris ALDERS:

Is there a way i can upload the project?



Public ClockTimer As Timer
Public PositionTimer As Timer
Public Frames As Integer
Public PreviousSeconds As Integer
Public VideoFile As String
Public $hhPlayer As MediaPlayer
Public hSink As MediaControl

Public Sub InitTimer_Timer()
  InitTimer.enabled = False
  Dialog.path = "." 
  
  Try $hhPlayer = New Mediaplayer As "MediaPlayer"
  Try hSink = New MediaControl($hhPlayer, "ximagesink")
  Try hSink.SetWindow(VideoDisplay, VideoDisplay.X, VideoDisplay.Y, 640, 360)
  Try $hhPlayer.Video.output = hSink
  If Error Then Print Error.text

  ClockTimer = New Timer As "ClockTimer"
  ClockTimer.delay = 40
  ClockTimer.enabled = True
  
  PositionTimer = New Timer As "PositionTimer"
  PositionTimer.delay = 40
  PositionTimer.enabled = True
End

Public Sub ClockTimer_Timer()
  If PreviousSeconds <> Str$(Second(Now)) Then Frames = 0
  ClockDisplay.text = Str$(Hour(Now)) & ":" 
  If Len(Str$(Minute(Now))) = 1 Then ClockDisplay.text = ClockDisplay.text & "0"
  ClockDisplay.text = ClockDisplay.Text & Str$(Minute(Now)) & ":" 
  If Len(Str$(Second(Now))) = 1 Then ClockDisplay.text = ClockDisplay.text & "0"
  ClockDisplay.text = ClockDisplay.Text & Str$(Second(Now)) & ":"
  If Len(Str$(frames)) = 1 Then ClockDisplay.text = ClockDisplay.text & "0"
  ClockDisplay.text = ClockDisplay.text & Str$(Frames)
  PreviousSeconds = Str$(Second(Now))
  Frames = Frames + 1
End


Public Sub OpenButton_Click()
  If Dialog.OpenFile(False) Then Return
  VideoFile = Dialog.path
  Print VideoFile
  Try $hhPlayer.url = Media.URL(VideoFile)
  Try hSink.SetWindow(VideoDisplay, VideoDisplay.X, VideoDisplay.Y, 640, 360)
  If Error Then
    PlayButton.enabled = False
    StopButton.enabled = False 
    Print Error.Text
    Message.Error(Error.text, "OK")   
  Else
    PlayButton.enabled = True
    StopButton.enabled = True
  Endif
End

Public Sub PlayButton_Click()
  Try $hhPlayer.Play
  If Error Then Print Error.text
End

Public Sub StopButton_Click()
  Try $hhPlayer.pause
End

Public Sub PositionTimer_Timer()
  PositionDisplay.text = JDate($hhPlayer.position)
End

Public Function JDate(Durat As Variant) As String
  Dim H As Integer
  Dim M As Integer
  Dim S As Integer
  Dim F As Integer
  Dim HH As String = "00"
  Dim MM As String = "00"
  Dim SS As String = "00"
  Dim FF As String = "00"
  Dim FPS As Integer
  Dim Dur As Integer

    FPS = 25
    
    Dur = Durat * 1000

    H = Dur / (3600 * 1000)
    Dur = Dur Mod (3600 * 1000)
    M = Dur / (60 * 1000)
    Dur = Dur Mod (60 * 1000)
    S = Dur / 1000
    Dur = Dur Mod 1000
    F = (Dur * FPS) / 1000

    HH = Str(H)
    MM = Str$(M)
    SS = Str$(S)
    FF = Str$(F)
    
    If Len(HH) = 1 Then HH = "0" & HH
    If Len(MM) = 1 Then MM = "0" & MM
    If Len(SS) = 1 Then SS = "0" & SS
    If Len(FF) = 1 Then FF = "0" & FF
    
  Return HH & ":" & MM & ":" & SS & ":" & FF

End

Joris ALDERS changed the state of the bug to: Accepted.







More information about the User mailing list