1

AxWindowsMediaPlayer can be used for showing images to user. If you set URL to example.png, image will be shown to user for exactly 5seconds (read from Ctlcontrols.currentPosition value).

Although image will be shown to user for 5seconds, value of "currentMedia.duration" equals to 0. Moreover you cannot set duration using setItemInfo to value you would like to.

Is there any way how to show image to user using AxWindowsMediaPlayer for eg. 37.5seconds? Is there any easy way how to change that interval for different images, or is it somewhere hard-coded constant?

I am sure that much better solution would be to use different components (eg. pictureBox and timer) but I am looking for solution using AxWindowsMediaPlayer. And I am sure that desired behavior could be done by changing current position for demanded period of time :-) - but I would like to avoid this.

Prereq: WinForms, .NET 4.0, WMP 12 for Windows 7

Thanks a lot

user2126375
  • 1,594
  • 12
  • 29
  • Have the lack of responses on your [other](http://stackoverflow.com/questions/18641519/axwindowsmediaplayer-black-component-when-starts-to-play-movie) [two](http://stackoverflow.com/questions/18641095/axwindowsmediaplayer-how-to-set-video-border-color-programmatically) questions perhaps given you an indication that there is more to do? It would be much more helpful if you posted code, errors you're receiving, and/or things you've tried. – crthompson Sep 05 '13 at 17:19
  • First - All three questions are related to the same subject (AxWindowsMediaPlayer) and I wrote all of them in a hour. So lack of responses is related to that short time of writing. There is no code which can be put here because there is nothing to repair in code or so - complete possible right solution is missing. Of course I have workarounds for all of my issues but still - these are workarounds and I am looking for native solutions. – user2126375 Sep 07 '13 at 16:12

1 Answers1

1

In PlayStateChange event handler detect 'newState == 3` (Playing).

After this, call wmp.Ctlcontrols.pause() and start timer. On timer.Tick event release paused media item.

To release pause call wmp.Ctlcontrols.play(), but be carrefull. This will trigger "newState == 3" again.

Also, timer interval should be substracted for 5 seconds, and you can't set slide to less than 5 seconds.

Sample bellow is not tested, but I implement something like this:

    private System.Windows.Forms.Timer timer;

    private void OnPlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        switch (e.newState)
        {
            case 3:
                if (!timer.Enabled)
                {
                    this.player.Ctlcontrols.pause();
                    this.timer.Interval = (37 - 5) * 1000; // 37 seconds 
                    this.timer.Start();
                }
                break;
        }
    }

    protected override void OnTimerTick(object sender, EventArgs e)
    {
        this.player.Ctlcontrols.play();
        this.timer.Stop();
    }
user431597
  • 26
  • 2
  • This solution could be working one. Meanwhile I created my user control with picturebox and wmp component. All is working as I described in my initial post. Big advantage of this approach is in possibility to use images from application resources without need to write them on HDD because showing them in WMP. – user2126375 Oct 09 '13 at 10:55