• 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

    • Mozilla shuts down even more Firefox services you might still be using by David Uzondu A few weeks ago, Mozilla announced that its Pocket and Fakespot services were getting the axe as the company focuses more on Firefox. It is a complete shutdown. Pocket, the read-it-later service Mozilla bought in 2017, will stop working on July 8, 2025. You have until October 8 to get your saved articles out before they are deleted forever. Fakespot, which helped you spot garbage product reviews, is also being sunsetted. But the house cleaning does not stop with those two. Neowin has spotted a shutdown notice dated June 26, 2025 for Deep Fake Detector, the Firefox extension that was supposed to tell you if a piece of text was written by a human or an AI chatbot. That tool used a combination of Mozilla's own proprietary ApolloDFT engine and open-source models like ZipPy to give you a verdict on what you were reading. The notice says: This brings us to the AI tools. Following the pattern, the Orbit website was updated with a banner that announced the service would shut down by June 26. Orbit was Mozilla's big privacy-first experiment in AI. It was a Firefox add-on that could summarize articles and answer questions about a webpage's content without sending your data to a third party. This is not an AI exit. Mozilla is simply changing how it delivers AI features. Orbit's private, self-contained setup can be replaced with the new sidebar built directly into Firefox, letting you connect to third-party chatbots like ChatGPT and Gemini. But, for Orbit users, this is still a huge loss, as a key feature of the service was privacy. Your prompts were handled by Mistral LLM (Mistral 7B) within Mozilla's GCP instance and were not shared with other companies for model training, which was a huge selling point for people tired of being the product. Mozilla keeps saying these cuts are necessary. As the only major browser not owned by a tech giant, its resources are limited; hence, the need to focus its cash and engineering talent on the core Firefox browser to compete.
    • Too close to the Ultra, I have and love an Ultra but have held onto my watch 6 classic because it is nicer when wearing a suit to work.
    • Intel v32.0.101.6881 graphics driver fixes a popular multiplayer hero shooter by Taras Buria Intel is rolling out a new graphics driver under version 32.0.101.6881. This WHQL release does not contain much. In fact, there is only a single fix for a popular multiplayer hero shooter. The new driver fixes crashes when launching Overwatch 2 (DirectX 12) on High or Ultra graphics settings on Intel Arc A-Series graphics cards. From the changelog: Overwatch 2 (DX12) may experience an application crash while launching the game with High or Ultra graphics quality settings. Known bugs in the drive include the following: Intel Arc B-Series Graphics Products: Fortnite may experience an application crash when “Performance - Lower Graphical Fidelity” is selected as Rendering Mode. Recommendation is to use default Rendering Mode – DX12. Visual corruptions may appear in certain scenarios with multiple application interactions. Call of Duty: Black Ops 6 (DX12) may exhibit flickering corruption in certain scenes during gameplay. Returnal (DX12) may experience an application crash during gameplay with Ray-Tracing settings turned on. Call of Duty: Warzone 2.0 (DX12) may exhibit corruptions on water areas in certain scenarios. SPECapc for Maya 2024 may experience intermittent application freeze during benchmark. PugetBench for Davinci Resolve Studio V19 may experience an application crash while running the benchmark. HWiNFO may incorrectly report number of Xe Cores for certain Intel Arc B-Series Graphics Products. Intel Arc A-Series Graphics Products: Returnal (DX12) may experience an application crash during gameplay with Ray-Tracing settings turned on. Marvel’s Spider-Man 2 (DX12) may experience an application crash with Ray-Tracing and XeSS enabled. PugetBench for Davinci Resolve Studio V19 may experience an application crash while running the benchmark. Intel Core Ultra Series 1 with built-in Intel Arc GPUs: Adobe Premiere Pro may fail to import video. Mitigation is to use Intel NPU Driver version 32.0.100.3717 or lower. PugetBench for Davinci Resolve Studio V19 may experience errors intermittently with benchmark preset set to Extended. Intel Core Ultra Series 2 with built-in Intel Arc GPUs: Valorant (DX11) may fail to enumerate supported resolutions in game settings. Adobe Premiere Pro may experience an intermittent application crash. Adobe Premiere Pro may fail to import video. Mitigation is to use Intel® NPU Driver version 32.0.100.3717 or lower. PugetBench for Davinci Resolve Studio V19 may experience errors intermittently with benchmark preset set to Extended. You can install Intel 32.0.101.6881 WHQL driver on PCs with 64-bit Windows 10 and Windows 11 with the following graphics products from Intel: Discrete GPUs Integrated GPUs Intel Arc A-Series (Alchemist) Intel Arc B-Series (Battlemage) Intel Iris Xe Discrete Graphics (DG1) Intel Core Ultra Series 2 (Lunar Lake and Arrow Lake) Intel Core Ultra (Meteor Lake) Intel Core 14th Gen (Raptor Lake Refresh) Intel Core 13th Gen (Raptor Lake) Intel Core 12th Gen (Alder Lake) Intel Core 11th Gen (Tiger Lake) You can download the driver from the official website here. Full release notes are available here (PDF).
    • Just look at the shiney shiney Vista clone, ignore the fact that they are a disaster in anything AI related. Roll on the class actions for all iPhone 16 owners.
  • Recent Achievements

    • Collaborator
      Carltonbar earned a badge
      Collaborator
    • Explorer
      MusicLover2112 went up a rank
      Explorer
    • Dedicated
      MadMung0 earned a badge
      Dedicated
    • Rookie
      CHUNWEI went up a rank
      Rookie
    • Enthusiast
      the420kid went up a rank
      Enthusiast
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      ATLien_0
      268
    3. 3
      +FloatingFatMan
      248
    4. 4
      +Edouard
      201
    5. 5
      snowy owl
      168
  • Tell a friend

    Love Neowin? Tell a friend!