无法使用MS视频控件来反向播放视频文件。 [英] Not to able to backward the video file using MS video control.

查看:102
本文介绍了无法使用MS视频控件来反向播放视频文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经使用MS Video Control加载了视频文件,但我无法向后移动 媒体帧使用自定义后退按钮。但是能够使用自定义滑块向后移动。


在滑块上向前和向后移动按钮调用相同的内容,例如: -



player.currentPosition = slider.value


即使按下前进按钮也是如此。



任何人都可以向后推荐玩家吗?


谢谢,


Yogi Arora












解决方案

Hi Yogi Arora,


感谢您在此发帖。


向后操作是视频的基本操作。我认为微软必须为视频控制提供类似的功能。


您是否检查过视频控件是否具有倒带功能和SetPosition功能?


如果控件具有两个功能,您可以使用指定的函数来实现向后功能。


这是PlayerSeeking类的声明。

 //实现搜索和速率控制功能。 

/ *
用法:

- 当你收到MF_TOPOSTATUS_READY会话事件时调用SetTopology。
- 为每个会话事件调用SessionEvent。
- 在关闭媒体会话之前调用Clear。
- 要使用传输状态协调速率更改请求,请将所有
停止,暂停和播放命令委派给PlayerSeeking类。

* /

class PlayerSeeking
{
class CritSec
{
private:
CRITICAL_SECTION m_criticalSection;
public:
CritSec()
{
InitializeCriticalSection(& m_criticalSection);
}
~CritSec()
{
DeleteCriticalSection(& m_criticalSection);
}
void Lock()
{
EnterCriticalSection(& m_criticalSection);
}
void Unlock()
{
LeaveCriticalSection(& m_criticalSection);
}
};

class AutoLock
{
private:
CritSec * m_pCriticalSection;
public:
AutoLock(CritSec& crit)
{
m_pCriticalSection =& crit;
m_pCriticalSection-> Lock();
}
~AutoLock()
{
m_pCriticalSection-> Unlock();
}
};

public:

PlayerSeeking();
virtual~PlayerSeeking();

HRESULT SetTopology(IMFMediaSession * pSession,IMFTopology * pTopology);
HRESULT Clear();
HRESULT SessionEvent(MediaEventType类型,HRESULT hrStatus,IMFMediaEvent * pEvent);

HRESULT CanSeek(BOOL * pbCanSeek);
HRESULT GetDuration(MFTIME * phnsDuration);
HRESULT GetCurrentPosition(MFTIME * phnsPosition);
HRESULT SetPosition(MFTIME hnsPosition);

HRESULT CanScrub(BOOL * pbCanScrub);
HRESULT磨砂膏(BOOL bScrub);

HRESULT CanFastForward(BOOL * pbCanFF);
HRESULT CanRewind(BOOL * pbCanRewind);
HRESULT SetRate(float fRate);
HRESULT FastForward();
HRESULT Rewind();

HRESULT Start();
HRESULT Pause();
HRESULT Stop();

私人:

enum命令
{
CmdNone = 0,
CmdStop,
CmdStart,
CmdPause ,
CmdSeek,
};

HRESULT SetPositionInternal(const MFTIME& hnsPosition);
HRESULT CommitRateChange(float fRate,BOOL bThin);
float GetNominalRate();

HRESULT OnSessionStart(HRESULT hr);
HRESULT OnSessionStop(HRESULT hr);
HRESULT OnSessionPause(HRESULT hr);
HRESULT OnSessionEnded(HRESULT hr);

HRESULT UpdatePendingCommands(命令cmd);

private:

//描述当前或请求的状态,关于寻求和
//播放率。
struct SeekState
{
命令命令;
float fRate; //播放率
BOOL bThin; //细化播放?
MFTIME hnsStart; //开始位置
};

BOOL m_bPending; //请求待处理吗?

SeekState m_state; //当前的名义状态。
SeekState m_request; // 待处理请求。

CritSec m_critsec; //保护搜索和速率变化状态。

DWORD m_caps; //会话上限
BOOL m_bCanScrub; //当前会话是否支持率= 0.

MFTIME m_hnsDuration; //当前演示文稿的持续时间。
float m_fPrevRate;

IMFMediaSession * m_pSession;
IMFRateControl * m_pRate;
IMFRateSupport * m_pRateSupport;
IMFPresentationClock * m_pClock;
};


最好的问候,


哈特


Hi,

I have loaded the video file using MS Video Control but I am not able to backward the  media frames using custom backward button. But able to backward using custom slider.

Calling same thing on slider moving backward and forward and backward button such as:-

player.currentPosition = slider.value

And even same thing working on hitting forward button.

Can anyone please suggest something on backward the player ?

Thanks,

Yogi Arora

解决方案

Hi Yogi Arora,

Thank you for posting here.

The backward operation is a basic operation for video. I think the Microsoft must provide a similar functionality for the video control.

Did you check that the video control has Rewind function and SetPosition function?

If the control has the two function, you could use the specified function to achieve the backward functionality.

Here is the declaration of the PlayerSeeking class.

// Implements seeking and rate control functionality.

/*
    Usage:

    - Call SetTopology when you get the MF_TOPOSTATUS_READY session event.
    - Call SessionEvent for each session event.
    - Call Clear before closing the Media Session.
    - To coordinate rate-change requests with transport state, delegate all 
      stop, pause, and play commands to the PlayerSeeking class.

*/

class PlayerSeeking 
{
    class CritSec
    {
    private:
        CRITICAL_SECTION m_criticalSection;
    public:
        CritSec()
        {
            InitializeCriticalSection(&m_criticalSection);
        }
        ~CritSec()
        {
            DeleteCriticalSection(&m_criticalSection);
        }
        void Lock()
        {
            EnterCriticalSection(&m_criticalSection);
        }
        void Unlock()
        {
            LeaveCriticalSection(&m_criticalSection);
        }
    };

    class AutoLock
    {
    private:
        CritSec *m_pCriticalSection;
    public:
        AutoLock(CritSec& crit)
        {
            m_pCriticalSection = &crit;
            m_pCriticalSection->Lock();
        }
        ~AutoLock()
        {
            m_pCriticalSection->Unlock();
        }
    };

public:

    PlayerSeeking();
    virtual ~PlayerSeeking();

    HRESULT SetTopology(IMFMediaSession *pSession, IMFTopology *pTopology);
    HRESULT Clear();
    HRESULT SessionEvent(MediaEventType type, HRESULT hrStatus, IMFMediaEvent *pEvent);

    HRESULT CanSeek(BOOL *pbCanSeek);
    HRESULT GetDuration(MFTIME *phnsDuration);
    HRESULT GetCurrentPosition(MFTIME *phnsPosition);
    HRESULT SetPosition(MFTIME hnsPosition);

    HRESULT CanScrub(BOOL *pbCanScrub);
    HRESULT Scrub(BOOL bScrub);

    HRESULT CanFastForward(BOOL *pbCanFF);
    HRESULT CanRewind(BOOL *pbCanRewind);
    HRESULT SetRate(float fRate);
    HRESULT FastForward();
    HRESULT Rewind();

    HRESULT Start();
    HRESULT Pause();
    HRESULT Stop();

private:

    enum Command
    {
        CmdNone = 0,
        CmdStop,
        CmdStart,
        CmdPause,
        CmdSeek,
    };

    HRESULT SetPositionInternal(const MFTIME &hnsPosition);
    HRESULT CommitRateChange(float fRate, BOOL bThin);
    float   GetNominalRate();

    HRESULT OnSessionStart(HRESULT hr);
    HRESULT OnSessionStop(HRESULT hr);
    HRESULT OnSessionPause(HRESULT hr);
    HRESULT OnSessionEnded(HRESULT hr);

    HRESULT UpdatePendingCommands(Command cmd);

private:

    // Describes the current or requested state, with respect to seeking and 
    // playback rate.
    struct SeekState
    {
        Command command;
        float   fRate;      // Playback rate
        BOOL    bThin;      // Thinned playback?
        MFTIME  hnsStart;   // Start position
    };

    BOOL        m_bPending;     // Is a request pending?

    SeekState   m_state;        // Current nominal state.
    SeekState   m_request;      // Pending request.

    CritSec     m_critsec;      // Protects the seeking and rate-change states.

    DWORD       m_caps;         // Session caps.
    BOOL        m_bCanScrub;    // Does the current session support rate = 0.

    MFTIME      m_hnsDuration;  // Duration of the current presentation.
    float       m_fPrevRate;

    IMFMediaSession         *m_pSession;
    IMFRateControl          *m_pRate;
    IMFRateSupport          *m_pRateSupport;
    IMFPresentationClock    *m_pClock;
};

Best Regards,

Hart


这篇关于无法使用MS视频控件来反向播放视频文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆