diff options
author | Monroe Linden <monroe@lindenlab.com> | 2009-10-12 17:21:26 -0700 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2009-10-12 17:21:26 -0700 |
commit | d02906b12ee335676e11ac883981e75f4df2cacc (patch) | |
tree | 223fd33e0b6e8f2c0aa599e117281314c489de7d /indra | |
parent | b5768a69b18936282cf55f0a1ecb72ba19849836 (diff) |
Added an optional "loaded_duration" parameter to the 'updated' message. This is the duration through which the time-based media has loaded, and should be between zero and the value of the "duration" parameter. If the parameter is not supplied, it will be implicitly set to the same value as the "duration" parameter, so the movie will appear fully loaded. This can be queried with LLPluginClassMedia::getLoadedDuration().
Made the "loaded_duration" parameter also implicitly set the progress percentage and send out MEDIA_EVENT_PROGRESS_UPDATED messages when it changes.
Made the quicktime plugin set the "loaded_duration" parameter in its update messages.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 23 | ||||
-rw-r--r-- | indra/llplugin/llpluginclassmedia.h | 2 | ||||
-rw-r--r-- | indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 14 |
3 files changed, 39 insertions, 0 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index e019cdcf21..2a343fd0c9 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -133,6 +133,7 @@ void LLPluginClassMedia::reset() mCurrentTime = 0.0f; mDuration = 0.0f; mCurrentRate = 0.0f; + mLoadedDuration = 0.0f; } void LLPluginClassMedia::idle(void) @@ -705,6 +706,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) bool time_duration_updated = false; + int previous_percent = mProgressPercent; if(message.hasValue("current_time")) { @@ -722,11 +724,32 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) mCurrentRate = message.getValueReal("current_rate"); } + if(message.hasValue("loaded_duration")) + { + mLoadedDuration = message.getValueReal("loaded_duration"); + time_duration_updated = true; + } + else + { + // If the message doesn't contain a loaded_duration param, assume it's equal to duration + mLoadedDuration = mDuration; + } + + // Calculate a percentage based on the loaded duration and total duration. + if(mDuration != 0.0f) // Don't divide by zero. + { + mProgressPercent = (int)((mLoadedDuration * 100.0f)/mDuration); + } + if(time_duration_updated) { mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_TIME_DURATION_UPDATED); } + if(previous_percent != mProgressPercent) + { + mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_PROGRESS_UPDATED); + } } else if(message_name == "media_status") { diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 97f2a11ef2..697deec353 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -231,6 +231,7 @@ public: F64 getCurrentTime(void) const { return mCurrentTime; }; F64 getDuration(void) const { return mDuration; }; F64 getCurrentPlayRate(void) { return mCurrentRate; }; + F64 getLoadedDuration(void) const { return mLoadedDuration; }; // Initialize the URL history of the plugin by sending // "init_history" message @@ -339,6 +340,7 @@ protected: F64 mCurrentTime; F64 mDuration; F64 mCurrentRate; + F64 mLoadedDuration; }; diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index fbda65120d..556865f771 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -103,6 +103,7 @@ private: message.setValueReal("current_time", getCurrentTime()); message.setValueReal("duration", getDuration()); message.setValueReal("current_rate", Fix2X(GetMovieRate(mMovieHandle))); + message.setValueReal("loaded_duration", getLoadedDuration()); } sendMessage(message); @@ -593,6 +594,19 @@ private: return (F64)duration / (F64)scale; }; + F64 getLoadedDuration() + { + TimeValue duration; + if(GetMaxLoadedTimeInMovie( mMovieHandle, &duration ) != noErr) + { + // If GetMaxLoadedTimeInMovie returns an error, return the full duration of the movie. + duration = GetMovieDuration( mMovieHandle ); + } + TimeValue scale = GetMovieTimeScale( mMovieHandle ); + + return (F64)duration / (F64)scale; + }; + F64 getCurrentTime() { TimeValue curr_time = GetMovieTime( mMovieHandle, 0 ); |