Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions libs/openFrameworks/video/ofMediaFoundationPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ bool SharedDXGLTexture::isLocked() {
//----------------------------------------------
bool SharedDXGLTexture::draw(ofPixels& apix) {
if (lock()) {
mOfTex->draw(0, 0);
if (mOfTex->isAllocated()) {
mOfTex->draw(0, 0);
}
unlock();
return true;
}
Expand Down Expand Up @@ -825,8 +827,11 @@ bool ofMediaFoundationPlayer::isInitialized() const {

//----------------------------------------------
void ofMediaFoundationPlayer::OnMediaEngineEvent(DWORD aEvent, DWORD_PTR param1, DWORD param2) {

if (aEvent == MF_MEDIA_ENGINE_EVENT_LOADEDMETADATA) {
if (!mBLoadAsync) {
updateDuration();
updateDimensions();
mBIsDoneAtomic.store(true);
mWaitCondition.notify_one();
}
Expand Down Expand Up @@ -1218,12 +1223,13 @@ void ofMediaFoundationPlayer::handleMEEvent(DWORD aevent) {
}
}
mBDone = false;
mWidth = 0.f;
mHeight = 0.f;
DWORD w, h;
if (SUCCEEDED(m_spMediaEngine->GetNativeVideoSize(&w, &h))) {
mWidth = w;
mHeight = h;
//mWidth = 0.f;
//mHeight = 0.f;
//DWORD w, h;
//if (SUCCEEDED(m_spMediaEngine->GetNativeVideoSize(&w, &h))) {
//mWidth = w;
//mHeight = h;
if(updateDimensions()) {

if (mMeTexture) {
if (mMeTexture->getWidth() != mWidth || mMeTexture->getHeight() != mHeight) {
Expand Down Expand Up @@ -1384,3 +1390,16 @@ void ofMediaFoundationPlayer::updateDuration() {
}
}

//-----------------------------------------
bool ofMediaFoundationPlayer::updateDimensions() {
mWidth = 0.f;
mHeight = 0.f;
DWORD w, h;
if (SUCCEEDED(m_spMediaEngine->GetNativeVideoSize(&w, &h))) {
mWidth = w;
mHeight = h;
return true;
}
return false;
}

1 change: 1 addition & 0 deletions libs/openFrameworks/video/ofMediaFoundationPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class ofMediaFoundationPlayer : public ofBaseVideoPlayer, public of::MediaEngine

void handleMEEvent(DWORD aevent);
void updateDuration();
bool updateDimensions();

std::shared_ptr<METexture> mMeTexture;

Expand Down