Commits

Monroe Linden committed 2679468

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.

Comments (0)

Files changed (3)

indra/llplugin/llpluginclassmedia.cpp

 	mCurrentTime = 0.0f;
 	mDuration = 0.0f;
 	mCurrentRate = 0.0f;
+	mLoadedDuration = 0.0f;
 }
 
 void LLPluginClassMedia::idle(void)
 			
 
 			bool time_duration_updated = false;
+			int previous_percent = mProgressPercent;
 
 			if(message.hasValue("current_time"))
 			{
 				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")
 		{

indra/llplugin/llpluginclassmedia.h

 	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 
 	F64				mCurrentTime;
 	F64				mDuration;
 	F64				mCurrentRate;
+	F64				mLoadedDuration;
 	
 };
 

indra/media_plugins/quicktime/media_plugin_quicktime.cpp

 			message.setValueReal("current_time", getCurrentTime());
 			message.setValueReal("duration", getDuration());
 			message.setValueReal("current_rate", Fix2X(GetMovieRate(mMovieHandle)));
+			message.setValueReal("loaded_duration", getLoadedDuration());
 		}
 			
 		sendMessage(message);
 		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 );