Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This adds a media_player_keep_if_same setting to ds::ui::MediaPlayer… #105

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion projects/viewers/src/ds/ui/media/media_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ auto INIT = []() {
mvs.mVideoNVDecode = ds::parseBoolean(theValue);
mediaPlayer.setSettings(mvs);
});

e.registerSpritePropertySetter<ds::ui::MediaPlayer>(
"media_player_keep_if_same",
[](ds::ui::MediaPlayer& mediaPlayer, const std::string& theValue, const std::string& fileReferrer) {
auto& mvs = mediaPlayer.getSettings();
mvs.mKeepIfSame = ds::parseBoolean(theValue);
mediaPlayer.setSettings(mvs);
});
});
return true;
}();
Expand Down Expand Up @@ -233,7 +241,12 @@ void MediaPlayer::loadMedia(const std::string& mediaPath, const bool initializeI
}

void MediaPlayer::loadMedia(const ds::Resource& reccy, const bool initializeImmediately) {
if (mInitialized) uninitialize();
if (mInitialized) {
// If the resource is the same, don't do anything.
if (mMediaViewerSettings.mKeepIfSame && reccy.getAbsoluteFilePath() == mResource.getAbsoluteFilePath()) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to checking the path you'll need to confirm if the cropping is the same for images here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one!

// If the resource is different, uninitialize and then set the new resource.
uninitialize();
}

mResource = reccy;

Expand Down
6 changes: 5 additions & 1 deletion projects/viewers/src/ds/ui/media/media_viewer_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ struct MediaViewerSettings {
, mVideoNVDecode(false)
, mPanoramicVideoInteractive(true)
, mVideoStreamingLatency(0.2)
, mVideoSplitAlpha(false) {}
, mVideoSplitAlpha(false)
, mKeepIfSame(false) {}

//--------------------Overall Settings -----------------------------------------//
/// The size to be calculated to fit inside when initially loading content
Expand Down Expand Up @@ -164,6 +165,9 @@ struct MediaViewerSettings {

/// render video as if lower half is the alpha channel
bool mVideoSplitAlpha;

/// don't unload the media if the same resource is set again
bool mKeepIfSame;
};

} // namespace ds::ui