Windows Media Player 9 and Visual Basic

Hi,
Does anyone know the new codes to operate WMP 9 in VB6?
For example, to play a file in my program.
Thanks!
j4ymzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

j4ymzAuthor Commented:
like for example, you could do this in VB with media player 7 and below...

1) PLaying a file -

mediaplayer.filename = Pathname

2) Setting autostart

mediaplayer.autostart = False

However now, with mediaplayer 9, these commands no longer work...
if anyone knows anything please help.

Thanks!
0
DeuceEECommented:
VB6? Good.

MSDN Links for WMP9 SDK:


Getting Started: http://msdn.microsoft.com/library/en-us/wmplay/mmp_sdk/usingwindowsmediaplayerwithvisualbasic.asp?frame=true
This one will get you started on how to implement WMP9 in your application.


Player Object: http://msdn.microsoft.com/library/en-us/wmplay/mmp_sdk/playerobject.asp?frame=true
This one has the methods that you can use with WMP9 (follow the links there for more).


To get you started, to play a file, use the URL property:
wmp.URL = "C:\Music\Song.mp3"

To receive events depending on the user interaction, just double click the WMP9 object on your form and select from the drop-down list of events on the right.


Does that help? Hope so.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yahayasCommented:
idle_mind,
   Hi I will like you to help me to write a code that will be able to show me the the names of the programs corrently running on the system.
   I will likeyou  tosend me your e mail.thhank you.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ZeyadssCommented:
can you guys give me an example of how to display visualization effects in Windows Media Player. I found out its just i dont know how to make most things work for the effects.

Example:
how can I create two buttons. One for previous effect and the other for next effect work?
The examples I found were

EFFECTS.currentEffect and EFFECTS.previousEffects. I dont know if these are to switch visualizations to the next.

If so can anyone explain how to make all the EFFECTS elements work by putting some examples for each and where can I make them be shown?

for example. I have a Label1 and I want it to view the name of the current visualization. how is that possible?

plz help so we can all understand...
PLZ!!
0
SteveDoaneCommented:
Great Question!  I have been desparately seeking this same answer regarding how to change the Media Player Visualization run time in VB.  I have read the Microsoft links above in exhaustive detail, and been "to the end of the Internet" looking.  the best I can do in VB is read the registry key value for the current visualization, and, if I change that reg value, (and restart by entire VB program), it will change only then to what I set.  It seems as though there is no way to do this simple task, or, that it has something to do with 3rd party "skins".  I have used every syntax I can think of for EFFECTS.currentEffect and EFFECTS.previousEffects to no avail.  I am writing a Juke Box MP3 song selector software and almost done 3 months/10,000 lines of code looking great - but can't do this simple, "last" task to put the icing on the cake!   Anyone with info, please email me as sdoane5@cox.net - would be greatly appreciated and you would make my year!
0
AniMateVBCommented:
Hi there y'all

I'm not a ver y high-level programmer but I also used the wmp9.ocx to create my own player in VB ,I did most of the programming in the main form , and it's all done very simple but  I got almost everything working , create new-,rename-,delete-,add files to playlist , read all visualizations and presets into combo and listbox , switch between genre/playlist , get all the files into a listview with corresponding names and duration.
If you want the full code just give your E-Mail adress and I'll send it.
The only thing i just don't get is how to get the INDEX of the current playing media item.
Maybe someone here can help with that , I tried the events which say CurrentItemChange/MediaChange , but I don't understand the (ByVal pdispMedia As Object)/(ByVal Item As Object) on how to retrieve the values.
Looking forward to seeing some response to this post.

Greetz,

AniMate
0
AniMateVBCommented:
Hi Again,

Correction on the last question , I got that covered now too , can set iteminfo , I did just that and give a certain iteminfo an indexnumber , and later on in the code I can retrieve that and let the list act accordingly.Also got the problem on making a slider act as the position slider in wmp9.

Greetz,

AniMate
0
vijay_rangarajCommented:
Hi AniMate,

    I need to know how to change the visualization in the media player control. can you please send me the code that does it to me at vijay_rangaraj@hotmail.com?

Thanks a lot.

Vijay Rangaraj K.
0
vijay_rangarajCommented:
Hi AniMate,

    Just a gentle reminder!! If you are willing to share your source code with me please send it to me at vijay_rangaraj@hotmail.com. I think it would help me a lot in controlling the visualization in the media player I'm developing.

Thanks a lot.

Vijay Rangaraj K.
0
AniMateVBCommented:
Hi vijay,

I'm sorry for not answering your question , but I'm in the middle of moving and my internet connection is also soon cancelled , so I hope you have a little more patience , I'll try to send the code to you as fast as I can , and BTW , I'm not using WMP9 but WMP8.

See Ya

AniMateVB
0
BobNHCommented:
AniMate,
Could you please send me the code also. I need to use WMP9, hopefully I could modify your code to work.


Thanks,
BobNH
0
ofeksanCommented:
Hey AniMateVB
Can u plz send me the code you wrote
regarding effects

10x
shoku@013.net.il
0
ofeksanCommented:
if someone is interested in a sample code for wmp in vb6
i have a sample of mine

hopefully after AniMateVB will send me his code
the sample will be more functional

anyway, send me your email and ill post it back to ya

gamgam
0
BobNHCommented:
gamgam,

Re:wmp in vb6
Would you please send what you have to:
bsma.bob.n@tir.com

Thank you
0
ofeksanCommented:
sure, i will
0
AniMateVBCommented:
Dim Vis As New WMPEffects 'Create Vis as WMPEffects Object for manipulating visualization effects
Dim Eff As New WMPLayoutSettings 'Create Eff as  WMPLayoutSettings for setting visualization effects

Private Sub EnumerateCombo() 'Fill the ComboBox with all the existing Effects as Titles
    Dim Viscount, names, VisNames
    Vis.allowAll = True
    Viscount = Vis.effectCount
    For names = 0 To Viscount - 1
        VisNames = Vis.effectTitle(names)
        Combo1.AddItem VisNames, names
    Next names
End Sub

Private Sub EnumerateList() 'Fill the ComboBox with all the existing Effects as Types
    Dim Viscount, names, VisNames
    Viscount = Vis.effectCount
    List1.Height = Viscount * 255
    For names = 0 To Viscount - 1
        VisNames = Vis.effectType(names)
        List1.AddItem VisNames, names
    Next names
End Sub

Private Sub EnumeratePre() 'Get all the visualization presets in the listbox
    Dim PreCount As String
    Dim naam, PreNames
    On Error Resume Next
    List4.Clear
    Vis.currentEffectType = Vis.effectType(txtIndex.Text)
    Eff.effectType = Vis.currentEffectType
    Eff.effectPreset = Vis.currentPreset
    PreCount = Vis.currentEffectPresetCount
    For naam = 0 To PreCount - 1
        List4.AddItem Vis.currentPresetTitle
        Vis.Next
    Next naam
End Sub

Private Sub EffectsSettings()
    GetEffect
    If Vis.effectHasPropertyPage = False Then
        MsgBox "This visualization has no properties you can set!", vbOKOnly, "AniMate's Media Player"
        Exit Sub
    End If
    Vis.settings
End Sub

Private Sub GetEffect()
    List1.ListIndex = Combo1.ListIndex
    Vis.currentEffectType = Vis.effectType(List1.ListIndex)
    Eff.effectType = Vis.currentEffectType
    Eff.effectPreset = Vis.currentPreset
End Sub

Private Sub Combo1_Click() 'Change visualization by clicking on combobox
    GetEffect
    WriteToINI "VIS", "ITEM", Combo1.ListIndex, App.Path & "\Settings.ini"
End Sub

Private Sub List1_Click() 'Change visualization by clicking on listbox
    Dim CombosInd As Long
    On Error Resume Next
    List1.ListIndex = Combo1.ListIndex
    CombosInd = List1.ListIndex
    Vis.currentEffectType = Vis.effectType(List1.ListIndex)
    Eff.effectType = Vis.currentEffectType
    If Vis.currentPreset = -1 Then
        Exit Sub
    Else
        Eff.effectPreset = Vis.currentPreset
        txtIndex.Text = CombosInd
        EnumeratePre
    End If
End Sub

Private Sub List4_Click() 'This sub wil put the selected vispreset and show it
    If Vis.currentEffectPresetCount = 1 Then
        Exit Sub
    Else
    If Vis.currentPreset = Vis.currentEffectPresetCount - 1 Then
        If Combo1.ListIndex = Combo1.ListCount - 1 Then
            Combo1.ListIndex = 0
            List1.ListIndex = Combo1.ListIndex
            Eff.effectType = Combo1.Text
            Eff.effectPreset = List4.ListIndex
        Else
            Vis.Next
            Combo1.ListIndex = Combo1.ListIndex + 1
            List1.ListIndex = Combo1.ListIndex
            Eff.effectType = Combo1.Text
            Eff.effectPreset = List4.ListIndex
        End If
    Else
        Eff.effectPreset = List4.ListIndex
    End If
    End If
    WriteToINI "VIS", "PRESET", List4.ListIndex, App.Path & "\Settings.ini"
End Sub

Hi Guys,
I arranged to put this answer for y'all through another persons internet connection because I still don't have one of my own.
I put all the code from my project that has to do with visualizations here , the only bit that I didn't put here is what is in the Form_load part.
Maybe also you have to look at your references in VB that you have the correct ones installed.
Hopefully this will help some of you to get the visualizations working right.
I'll be periodically looking at this Topic

Greetz.

AniMate
0
BobNHCommented:
AniMate or anyone else who can help,

Re:
Dim Vis As New WMPEffects 'Create Vis as WMPEffects Object for manipulating visualization effects
Dim Eff As New WMPLayoutSettings 'Create Eff as  WMPLayoutSettings for setting visualization effects

Dim Vis As New WMPEffects, works ok

Dim Eff As New WMPLayoutSettings, I cannot find any reference that this applies to.

Re:
Private Sub EnumerateCombo() 'Fill the ComboBox with all the existing Effects as Titles
    Dim Viscount, names, VisNames

    Vis.allowAll = True
    Viscount = Vis.effectCount
    For names = 0 To Viscount - 1
        VisNames = Vis.effectTitle(names)
        Combo1.AddItem VisNames, names
    Next names

End Sub

Vis.allowAll = True(or any other Vis method) produces Error 429, Actives component cannot create object. I have registered all WMP dll's and ocx's

When I look at WMPEffects with Object Browser, it shows it as:

Class WMPEffects
    Member of WMPLib
    WMPEffects: Not Public.  Internal object used by Windows Media Player.

Is the fact that the Class is 'Not Public' the problem?

Thanks,
Bob Hiller
0
JJOhioCommented:
I need to be able to place a next and a previous button on my application to step through the visualizations in windows media 9.

Has anybody figured this out yet?

Jim
0
BobNHCommented:
Jim,
Have you figured out how to even show a visualization in WMP 9?

Thanks,
Bob Hiller
0
JJOhioCommented:
well in my vb6 application, i simplay placed the player on a form and turned the play controls off and the visualizations show in the window.

if I run windows media player, and change the visualization and then run my program, the visualization that appears is the one i choose in windows media player.

However i want to place a couple buttons on my vb6 program that will allow the user to step thru the visualizations and I can not figure that part out.

Thats why I replied to this and then you replied and asked me the same question.

Jim
0
BobNHCommented:
Jim,
I don't see it as the same question but it really does not matter. If someone can get the code posted by AniMate to instantiate the WMP objects correctly, I think the rest of the code does what you need. Better said, what we need.

Thanks again,
Bob Hiller
0
aegrayCommented:
You can't access this object with WMP 9 object.  Just in case you haven't found this yet, wmp 10 sdk is now out and lets you mess with the visualizations.

download it here:

http://msdn.microsoft.com/library/default.asp?url=/downloads/list/winmedia.asp
0
AniMateVBCommented:
I recently also installed windows xp sp2 with automatically installed WMP9 , i also found out that a lot of stuff doesn't work anymore , so I will install WMP10 + SDK and take a look a that , it's really dissapointing that all my work is for nothing , but i'll keep on trying.

See ya all later

AniMateVB
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.