0

In a Windows Form Application, (Windows 7, VB), I've added a WMP control named WMPlayer and a listbox (lstMusic) containing a few filenames of music (mp3).
When the form loads, the play button is disabled until I click on a song to play, at which time I use the
WMPlayer.URL (fstMusic.selecteditem.tostring) statement and the song plays and play button is enabled. When I click the stop button, what I would like is to disable the play
button. I assume the play button will be enabled with the next WMPlayer.URL (fstMusic.selecteditem.tostring) encountered . If that answer is easily available, I can't find it.

Any help will be appreciated.

Thank you,
Paul

3
Contributors
9
Replies
32
Views
8 Months
Discussion Span
Last Post by Reverend Jim
0

Language. You asked to "disable the play" and not stop playback. So I would be guessing what you meant. Since controls can be disabled I have to guess you mean what you wrote.

Solution: In the handler for the stop button. Disable the play button. Remember you didn't share what language so in psuedo code it's something like playbutton.enabled = false;

0

If the answer were that easy, I would not have asked the question.
Yes, I wish to disable the play button. But, xxx.playbutton.enable = False is not an option. The language
is Visual Studio 2015, VB option. The play button, as far as I can see, doesn't have a name that
is easily accessible. Please read my statement again. I simply wish to disable the play button when I get control
within my application but I don't know the name of the Play button so I can disable it.

Thank you for your quick response.

1

The Microsoft documentation for the use of embedded WMP is obtuse at best. It describes the pieces without giving any useful information on how to use them. Having said that, I have not found a way to enable/disable the individual controls. They appear to be managed by the object itself and only change states as required when you "press" the given controls as exposed through the IWMPControls collection. If you are interested in my use of embedded wmp you can have a look at this article that I posted two years or so back.

0

Thank you Reverend Jim, I'll stop looking for a way to manage these imbedded controls. It would be nice if
it were as easy as WMPlayer.playbutton.enabled = False. Using the WMP from the Components toolbox is
easy but the user has little, if any, control over the buttons.

I'll now mark this as answered.

0

@OP. Not to leave you without exits. The following is something we can leverage to get a video player in our app fairly easily without adding 3rd party tools.

We can play videos in web browsers. Controls are then possible in the usual javascript, HTML that the web element would use.

If I were to do this again, I'd use the Web component or think about VLC in Visual Studio. There are many priors and how-tos today.
https://www.youtube.com/watch?v=09MhJS6jVn0

0

I tried to use VLC embedded in a vb.net form when I did my app and I couldn't get it to play then. I went through the youtube video today and had the same result. No errors but nothing plays. I even used Visual Studio 2010 like in the video.

Edited by Reverend Jim

0

@RJ, the last time I did this I used the web component to play video. It's native so I avoided adding 3rd part items.

1

Ah. As is the case with so may online tutorials, they get you 99% of the way there then leave out the 1% that actually makes it work. In the example, you load the video into the playlist by executing

vlc.playlist.add(OpenFileDialog1.FileName)

In ac tuality, what you have to execute is

vlc.playlist.add("file:///" & OpenFileDialog1.FileName)

Once I made that change the video played. That's sort of an important thing to leave out. Another thing I find with sample code and/or tutorials is when they leave out

  • What Imports are required for the code to work
  • What references must be added to the project for the code to work

These are the things that the "experts" omit because they assume that everyone else knows to add them, but they forget that if the people who watch the videos already knew what to do then they wouldn't be watching the videos.

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.