Windows Media Player

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Windows Media Player

Post by spectrum »

I don't know if anyone has a good link or ideas how to use a Wndows Media Player on a form. I can understand creating a path/URL for it, but is there a way to enlarge it? I have tried stretching it in design, but on opening and closing the form it shrinks again having a canvas area (similar appearance to paint app)

I have played with properties but cannot seem to find anything. Also, I don't know if it's beacause I have an open URL (ie no path), when I open the form the media player looks very strange as though other objects on the form are overlapping.

Thanks

User avatar
HansV
Administrator
Posts: 78241
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Windows Media Player

Post by HansV »

You can use code in the On Open or On Load event of the form:

Code: Select all

Private Sub Form_Load()
    With Me.WindowsMediaPlayer0
        .Width = 6 * 1440
        .Height = 5 * 1440
        .Object.URL = "file://C:\Videos\Lion_seul.mpeg"
    End With
End Sub
Height and width are specified in twips, where 1 inch = 1440 twips.
Best wishes,
Hans

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Windows Media Player

Post by spectrum »

Thanyou Hans, excellent.

There seems very little information easily found on using this control in Access. Best regards

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Windows Media Player

Post by spectrum »

Well I have a form, a Windows Media control sensibly sized, a Listbox providing URL 's of .mpg's. However everytime a list selection is made, the same picture (still) appears in the player, it momentarily says it's playing the video (shows name), but nothing moves . If I click on the start button on the control again it says momentarily it's playing but nothing moves?

Any clues? Thanks

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Windows Media Player

Post by spectrum »

Bit embarrasing, I went through the references to see if there were any relevant references to the media control, and tried the ActiveX objects library and now it's working. Sorry I should have checked a bit more before shouting help.

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Windows Media Player

Post by spectrum »

I Don't believe it, went back and opened the form and it's stopped working again, just shows a still image which does not change when selecting another URL in the listbox. Nothing moves, says it's playing, shows video title. ???

User avatar
HansV
Administrator
Posts: 78241
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Windows Media Player

Post by HansV »

I don't think you need any special references. Code like this should work:

Code: Select all

Private Sub lstVideos_Click()
    Me.wmpPlayer.Object.URL = "C:\Videos\" & Me.lstVideos
End Sub
where lstVideos is the list box containing file names, C:\Videos\ is the folder containing the files, and wmpPlayer is the name of the Windows Media Player object.
Best wishes,
Hans

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Windows Media Player

Post by spectrum »

Thankyou Hans for sorting out my wrongful postings.
I have found if I change the size settings of the WMP (I put the WMP sizes in the form open event), when I reopen the form the WMP is frozen, but if I change the size and then close and open Access it works perfectly from then on? I thought maybe it was a memory problem, the size causing a problem, however when it's working ok it lets me double click on the video and see it full screen.
So for the time being I'm moving on okay. One question, is there syntax for making it loop? Thanks

User avatar
HansV
Administrator
Posts: 78241
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Windows Media Player

Post by HansV »

A primitive way to make it play repeatedly:

Me.wmpPlayer.Object.settings.playCount = 1000
Best wishes,
Hans

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Windows Media Player

Post by spectrum »

It might be primitive to you Hans, but it's perfect for me.
I thought it might have been impossible to overide once set, but selecting another clip starts it all off again nicely. So thankyou very much.

User avatar
ankaka
NewLounger
Posts: 1
Joined: 15 Feb 2012, 06:52

Re: Windows Media Player

Post by ankaka »

Sorry can't be of any help. You can Google it of course, for a lot of opinions.