我在工程中使用Media Player控件,现在遇到一个这样的问题,如何得到我正在播放的文件的播放位置
我添加了OnPositionChangeOcxPlayer事件的响应函数,可以得到media player中进度条拖动的位置,但是当文件播放时,我得不到正在播放的位置,谁知道怎么做吗?

解决方案 »

  1.   

    我用DirectShow ,没用过这个,帮你up
      

  2.   

    PositionChange Event
    Control Events 
    Indicates changes to the current media position, such as when the user selects (or seeks to) a new media position. Private Sub object_PositionChange(ByVal oldPosition As Double, ByVal newPosition As Double)Parameters
    object 
    Object expression that evaluates to an ActiveMovie Control. 
    oldPosition 
    Position before it changed, in seconds. 
    newPosition 
    Current position, in seconds, after the position change occurred. 
    Res
    Changes made directly to the CurrentPosition property do not trigger this event. 
      

  3.   

    CurrentPosition Property
    Control Properties 
    Specifies the current position within the multimedia stream, in seconds. [form.]object.CurrentPosition [ = double ]Res
    The new value must be within the range specified by the SelectionStart and SelectionEnd properties. The current position value displayed by the control's user interface can represent either seconds or frames. The DisplayMode property determines the units shown. Setting the CurrentPosition property at run time is similar to a seek operation and changes the position to the specified point in the multimedia stream. Run-time access: read/write. Design-time access: not applicable. Settings Setting  Description  
    double  New position within the stream, in seconds.  
    Data Type double 
      

  4.   

    楼上的,我已经说过了,第一个change消息,只能在拖动进度条的时候得到,而不能在播放的时候得到;第二个,只是一个函数,我用一个线程函数去读取文件的播放位置,然而这样的效果并不好。所以想请大家想想有什么好的办法
      

  5.   

    IMediaSeeking* pMS = NULL;
              LONGLONG llPosition = 0;
    pMS->GetCurrentPosition(&llPosition);
      

  6.   

    double CMediaPlayer2::GetCurrentPosition()
    {
    double result;
    InvokeHelper(0x403, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL);
    return result;
    }
    这个函数可以得到。不管什么时候都可以。