Solved

Windows Media Player 9 and Visual Basic

Posted on 2003-11-04
23
75,491 Views
Last Modified: 2013-12-20
Hi,
Does anyone know the new codes to operate WMP 9 in VB6?
For example, to play a file in my program.
Thanks!
0
Comment
Question by:j4ymz
  • 5
  • 5
  • 3
  • +8
23 Comments
 

Author Comment

by:j4ymz
Comment Utility
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
 
LVL 1

Accepted Solution

by:
DeuceEE earned 50 total points
Comment Utility
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
 

Expert Comment

by:yahayas
Comment Utility
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
 
LVL 2

Expert Comment

by:Zeyadss
Comment Utility
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
 

Expert Comment

by:SteveDoane
Comment Utility
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
 

Expert Comment

by:AniMateVB
Comment Utility
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
 

Expert Comment

by:AniMateVB
Comment Utility
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
 

Expert Comment

by:vijay_rangaraj
Comment Utility
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
 

Expert Comment

by:vijay_rangaraj
Comment Utility
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
 

Expert Comment

by:AniMateVB
Comment Utility
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
 

Expert Comment

by:BobNH
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Expert Comment

by:ofeksan
Comment Utility
Hey AniMateVB
Can u plz send me the code you wrote
regarding effects

10x
shoku@013.net.il
0
 

Expert Comment

by:ofeksan
Comment Utility
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
 

Expert Comment

by:BobNH
Comment Utility
gamgam,

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

Thank you
0
 

Expert Comment

by:ofeksan
Comment Utility
sure, i will
0
 

Expert Comment

by:AniMateVB
Comment Utility
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
 

Expert Comment

by:BobNH
Comment Utility
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
 

Expert Comment

by:JJOhio
Comment Utility
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
 

Expert Comment

by:BobNH
Comment Utility
Jim,
Have you figured out how to even show a visualization in WMP 9?

Thanks,
Bob Hiller
0
 

Expert Comment

by:JJOhio
Comment Utility
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
 

Expert Comment

by:BobNH
Comment Utility
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
 

Expert Comment

by:aegray
Comment Utility
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
 

Expert Comment

by:AniMateVB
Comment Utility
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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now