Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1 view
Skip to first unread message

dicky...@gmail.com

unread,
Jun 21, 2017, 8:38:19 AM6/21/17
to
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") Then
Set 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
0 new messages