PlayAtTime freezing

Oct 28, 2009 at 4:42 PM
Edited Oct 28, 2009 at 4:44 PM


Hi.  I'm stumped.  I'm trying to use PlayAtTime at it's freezing:

IDvdCmd dvdCmd;
int hr = m_dvdCtrl.PlayAtTime(timeCode, DvdCmdFlags.Flush | DvdCmdFlags.SendEvents, out dvdCmd);

The instant I press the button the runs this code (while the video is playing), the video freezes and eventually crashes.

However, the PlayAtTime works successfully if I (1) hit pause, (2) run the playattime code, (3) hit play.  So I tried adding my pause code before the playattime code and the play code after the playattime code and it didn't work. 

I'm stumped no error.  Just a frozen screen and windows asking if I want to wait for the program to respond.

My pause code is: 


My play code is:



Does anyone know what might be going happening?  Thanks.

Oct 30, 2009 at 11:23 PM

Thanks for the detailed report!  I'll try to get at it asap.  Just a lil backlogged, or maybe perpetually backlogged :).

The Run(), and Pause() aren't really totally synchronous operations (They can block long enough to momentarily freeze the UI thread, so that's why it's ran under it's own), but in reality, send messages to another thread internally.

What happens if you change your code, not in the DvdPlayer.cs, but in the DvdPlayerElement.cs.  In the PlayAtTime, you first run a this.Pause(); /* ... Current Code */ this.Play();

If nothing happens, for testing, try putting a Thread.Sleep() of a second or so between you m_mediaCtrl.Pause() and Run() and lemme know if that does anything.


Nov 4, 2009 at 10:40 PM


Thank you for your reply.  I've made some progress in figuring out what's going on:

First, in answer to your questions.

>What happens if you change your code....this.Pause(); /* ... Current Code */ this.Play();

:)  Yeah... that was the first thing I did.  It still failed. 

I also tried:

....this.Pause(); Thread.Sleep(1000);  /* ... Current Code */ Thread.Sleep(1000);  this.Play();  That failed too.

As for a solution in my code.... I have a "GetCurrentTitleTime()" that executes during my DvdChapterStart event.  If I take it out, PlayAtTime() works fine. 

So.... if I have this is code running, PlayAtTime fails:

case EventCode.DvdChapterStart: //event for handling chapter start                           
     dvd_Info.TotalTime = m_player.GetCurrentTitleTime();

If I hard code the length of my movie, PlayAtTime() works fine:

case EventCode.DvdChapterStart: //event for handling chapter start
     DvdHMSFTimeCode myTime = new DvdHMSFTimeCode();
     myTime.bHours = 1;
     myTime.bMinutes = 36;
     myTime.bSeconds = 12;
     myTime.bFrames = 5;
     dvd_Info.TotalTime = myTime;

This is the case even though "dvd_Info.TotalTime = m_player.GetCurrentTitleTime();" appears to be working fine, returns the correct TimeCode, and does not produce any errors.  The function called is:

        public DvdHMSFTimeCode GetCurrentTitleTime()
            DvdHMSFTimeCode pTotalTime = new DvdHMSFTimeCode();
            if (this.m_dvdInfo != null)
                DvdTimeCodeFlags flags;
                this.m_dvdInfo.GetTotalTitleTime(pTotalTime, out flags);                
            return pTotalTime;

Thank you for any suggestions.