• 0

Question

Hello gang,

I had to switch an app from VLC to WMP (VLC is a great media player, but the 2.0 version affected all the interfaces so...)

I am trying to find the event that gets fired when a local file has completed playing. The EndOfStream does not file for local files (drat) and the PlayStateChange fires twice for "WMPLib.WMPPlayState.wmppsStopped" I could set a local variable, but before I got down that Hack Path I wanted to see if anyone knows of the proper event.

thanks.

Link to comment
https://www.neowin.net/forum/topic/1065850-net-wmp-end-of-file/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Just took a quick look at the documentation: it seems that when the PlayStateChange event is fired, you need to check the argument passed (which is an integer) to determine what happened. In particular, the value 8 means "MediaEnded", which might be what you need. See http://msdn.microsoft.com/en-us/library/windows/desktop/dd562460(v=vs.85).aspx

  • 0
  On 25/03/2012 at 23:57, Dr_Asik said:

Just took a quick look at the documentation: it seems that when the PlayStateChange event is fired, you need to check the argument passed (which is an integer) to determine what happened. In particular, the value 8 means "MediaEnded", which might be what you need. See http://msdn.microsof...0(v=vs.85).aspx

Thanks, but I knew that. This value: "WMPLib.WMPPlayState.wmppsStopped" is number 8. I have a small test bed but when that code runs and calls a "NextMedia" function, that function does not run. I have taken the advice I found elsewhere in that I have a timer (hack!) that is enabled when the media stops (hack!) and that calls the "NextMedia", which works (HACK!)

Very strange.

  • 0

Strange indeed, I can't reproduce your problem. Here's what I tried:

- Created a new Winforms project

- Added a reference to Windows Media Player (File Version 12.0.7601.17514, there was a second one but older)

- Added the control to the toolbox, dragged it on the form, renamed it to mediaPlayer

- Added a menu to open a file

- Added the following code:

using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace WmpTest {
public partial class Form1 : Form {

public Form1() {
InitializeComponent();
mediaPlayer.PlayStateChange += mediaPlayer_PlayStateChange;
}
void mediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) {
if (e.newState == (int)WMPLib.WMPPlayState.wmppsMediaEnded) {
Debug.WriteLine("Got MediaEnded event");
}
}
void ouvrirToolStripMenuItem_Click(object sender, EventArgs e) {
var openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK) {
mediaPlayer.URL = openFileDialog.FileName;
}
}
}
}[/CODE]

When a file finishes playing, I only see "Got MediaEnded event" once in the Debug output window.

  • 0

Here's some code that you can use in your PlayStateChange event handler to see what is triggered in what order:

var enumValues = (int[])Enum.GetValues(typeof(WMPLib.WMPPlayState));
var enumNames = Enum.GetNames(typeof(WMPLib.WMPPlayState));
for(int i = 0; i < enumValues.Length; ++i) {
if (e.newState == enumValues[i]) {
Debug.WriteLine(enumNames[i]);
}
}[/CODE]

It'll print the names of all the events in the Output window of Visual Studio during debugging. This is what I see when I set the URL and let it play to completion:

wmppsTransitioning

wmppsTransitioning

wmppsPlaying

wmppsMediaEnded

wmppsTransitioning

wmppsStopped

This topic is now closed to further replies.
  • Posts

    • YouTube comments are not displaying correctly for some users by Aditya Tiwari Image by ElisaRiva via Pixabay YouTube comments have long been used to express opinions, ask questions, provide feedback, share insights, or simply react to the video you're watching. However, this can sometimes go south, and unexpected bugs can ruin the experience. The Google-owned video sharing platform reached out to its community support forum to announce that YouTube comments are not displaying correctly for some users. YouTube has listed various ways the known issue can appear on your screen. For instance, comments are only visible when the "Newest First" filter is chosen; they might disappear or hide when "Top Comments" is selected, or they may not display at all. Some users may not be able to sort comments by "Top Comments," or their comments may disappear after being posted. "We're aware that some of you are experiencing an issue where comments aren't showing up beneath certain videos, and we're looking into it now," YouTube said, adding that it will follow up on the issue with an update. However, it didn't mention the regions where the problem is most prominent or specify the platforms (Android, iOS, or desktop) that are affected. This comes about a week after YouTube ran into a different problem: the bottom navigation bar on its Android app wasn't displaying for users in different countries. YouTube has now marked that issue as fixed. In recent updates, the video streaming giant took down a video that taught people how to self-host their media, citing policy violations. Its latest update for iOS brings bad news for people running old iPhones; several of them are now incompatible with the YouTube app. While YouTube has introduced features like Google Lens for Shorts, voting for playlists, and trending podcasts charts, it plans to insert more ads into its cheaper premium tier later this month.
    • I think it was even showed off during presentation it looked like a windows taskbar and windows icon during part. It also had the task view button looking at it. 1:07 during the "ROG Xbox Ally World Premier Reveal Trailer | Xbox Games showcase" - https://youtu.be/FIVmyOIV1MQ?t=64 Other than the lack of clock it looked like some custom explorer implementation. The appeal would extend well beyond students. While the handheld might suit that crowd, a pre-configured "Xbox Gaming PC" line could be the perfect answer for players overwhelmed by GPU choices or by which pre-built to buy when they don’t want to build from scratch. It would provide a hassle-free and upgrade-friendly platform. Imagine "Xbox PC 1" today, then "Xbox PC 3" a few years later. If other vendors follow suit (and they probably will), a standardized performance score, similar to the old Windows Experience Index, could make comparing systems straightforward also. (i think that's the way they will go, some sort of index with listed certified systems you can check game performance in. Say they have a score of 5, you know games that have a 5 or above will run fine.) EDIT: We also know it can run windows software, people have used steam on it and installed other games. So it must be able to run Windows executables already. If it does not ship with Windows Explorer it can be made to work for it.
    • Yes! I have long thought the xbox should have a desktop mode. Even if it isn't a full Windows system, just a browser, file manager, photo/video viewer, and office apps would be all most people need. I imagine such a device would be very popular among students who both want a console and need a computer.
    • That being true does not excuse the mainstream product's level of inefficiency.
  • Recent Achievements

    • Enthusiast
      the420kid went up a rank
      Enthusiast
    • Conversation Starter
      NeoToad777 earned a badge
      Conversation Starter
    • Week One Done
      VicByrd earned a badge
      Week One Done
    • Reacting Well
      NeoToad777 earned a badge
      Reacting Well
    • Reacting Well
      eric79XXL earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      472
    2. 2
      +FloatingFatMan
      278
    3. 3
      ATLien_0
      246
    4. 4
      snowy owl
      205
    5. 5
      Edouard
      190
  • Tell a friend

    Love Neowin? Tell a friend!