Results 1 to 5 of 5

Thread: Excel VBA with Windows Media Player: Runtime error while getting video timecode

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Jun 2017
    Posts
    3
    Location

    Excel VBA with Windows Media Player: Runtime error while getting video timecode

    I've added a Windows Media Player ActiveX control (WMPlayer2) and two command buttons, viz, cmd_PlayVideo and cmd_GetTimeCode on an Excel sheet. I would like to play a video in Windows Media Player and capture the timecode of the video as and when I click the cmd_GetTimeCode button while the video is being played.

    Since the 'currentPositionTimecode' property is available in IWMPControls3 interface, I've cast the return value from WMPlayer2.controls to the IWMPControls3 interface. However, the line 'MsgBox controls.currentPositionTimecode' throws: run-time error 430: "Class does not support Automation or does not support expected interface." The other properties of the IWMPControls3 interface such as audioLanguageCount, currentAudioLanguage, currentItem, controls.getAudioLanguageID, getLanguageName, and getAudioLanguageDescription work fine.

    How can I get the timecode of the video?
    Here is my code in 2 buttons.
    -------------------------------------------------------------------------

    Private Sub cmd_PlayVideo_Click()
    
    MsgBox Application.Sheets("Sheet1").Range("B2")
    WMPlayer2.URL = Application.Sheets("Sheet1").Range("B2")
    
    End Sub
    -------------------------------------------------------------------------

    Private Sub cmd_GetTimeCode_Click()
    
    Dim controls As WMPLib.IWMPControls3
    Dim Media As WMPLib.IWMPMedia
    Set controls = WMPlayer2.controls
    
    MsgBox controls.audioLanguageCount
    MsgBox controls.currentAudioLanguage
    If controls.isAvailable("currentItem") ThenSet Media = controls.currentItem
    MsgBox Media.durationString
    MsgBox Media.Name
    MsgBox Media.SourceUrl
    End If
    
    MsgBox controls.getAudioLanguageID(1)
    MsgBox controls.getLanguageName(1)
    MsgBox controls.getAudioLanguageDescription(1)
    MsgBox controls.currentPositionTimecode
    
    End Sub
    Last edited by SamT; 06-19-2017 at 06:09 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •