openframeworks / openframeworks/openFrameworks

ofDirectShowPlayer - isPlaying() sometimes returns false even after play() is called and video is rendering

Open
#6,552 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

This is a bug in the Windows ofVideoPlayer. I'm not getting it on Gstreamer under Linux. Haven't tested Mac OS. I'm using VS2017 community.

I discovered that isPlaying() seems to sporadically return false using the Windows direct show ofVideoPlayer, even after the file has successfully started playing.

The issue appears to be in updatePlayState() :

    void updatePlayState(){
        if( bVideoOpened ){
            FILTER_STATE fs;
            hr = m_pControl->GetState(4000, (OAFilterState*)&fs);
            if(hr==S_OK){
                if( fs == State_Running ){
                    bPlaying = true; 
                    bPaused = false;
                }
                else if( fs == State_Paused ){
                    bPlaying = false;
                    bPaused = true;
                }else if( fs == State_Stopped ){
                    bPlaying = false;
                    bPaused = false;
                }
            }
        }
    }

The line that occasionally, mysteriously fails for me is:

hr = m_pControl->GetState(4000, (OAFilterState*)&fs);

if the return value isn't S_OK, which is sometimes the case, bPlaying is never set to true, even if the file is playing healthily. A later call to play() will fix this.

You can reproduce this issue by adding the following line in the update() function of the videoPlayerExample:

ofLogNotice() << "video is playing: " << fingerMovie.isPlaying();

Sometimes the result will be true, sometimes false.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with updatePlayState() and its callers in the Windows ofVideoPlayer implementation, then reproduce the behavior in videoPlayerExample using the added isPlaying() log. Inspect the DirectShow GetState() result and compare it with the observed rendering state; done means isPlaying() consistently reports playback while the video is rendering.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.