Solved

Windows Media Player 9 and Visual Basic

Posted on 2003-11-04
23
75,522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
  • +8
23 Comments
 

Author Comment

by:j4ymz
ID: 9689491
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
ID: 9698588
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
ID: 10422514
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 2

Expert Comment

by:Zeyadss
ID: 10654424
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
ID: 10654786
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
ID: 11099591
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
ID: 11102838
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
ID: 11115521
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
ID: 11177329
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
ID: 11227179
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
ID: 11726059
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
 

Expert Comment

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

10x
shoku@013.net.il
0
 

Expert Comment

by:ofeksan
ID: 11818805
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
ID: 11818877
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
ID: 11818991
sure, i will
0
 

Expert Comment

by:AniMateVB
ID: 12005869
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
ID: 12008046
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
ID: 12020109
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
ID: 12020403
Jim,
Have you figured out how to even show a visualization in WMP 9?

Thanks,
Bob Hiller
0
 

Expert Comment

by:JJOhio
ID: 12020594
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
ID: 12020861
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
ID: 12224627
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
ID: 12286343
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 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