Link to home
Start Free TrialLog in
Avatar of j4ymz
j4ymz

asked on

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!
Avatar of j4ymz
j4ymz

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of DeuceEE
DeuceEE

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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!!
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!
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
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
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.
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.
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
AniMate,
Could you please send me the code also. I need to use WMP9, hopefully I could modify your code to work.


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

10x
shoku@013.net.il
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
gamgam,

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

Thank you
sure, i will
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
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
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
Jim,
Have you figured out how to even show a visualization in WMP 9?

Thanks,
Bob Hiller
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
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
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
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