Push the policy that "back", "forward" and "stop" do different things out of LLViewerMedia.

Now, LLViewerMedia has explicit skipBack() and skipForward()
functions, and the buttons in LLPanelPrimMediaControls now map
onto those functions neatly.
meow-7.2.2
Rick Pasetto 2009-11-19 18:34:37 -08:00
parent 98d54377f9
commit a8b603f33e
6 changed files with 63 additions and 49 deletions

View File

@ -54,6 +54,7 @@
#include "llpanelprimmediacontrols.h"
#include "llpluginclassmedia.h"
#include "llprogressbar.h"
#include "llstring.h"
#include "llviewercontrol.h"
#include "llviewerparcelmgr.h"
#include "llviewermedia.h"
@ -92,6 +93,7 @@ LLPanelPrimMediaControls::LLPanelPrimMediaControls() :
mCommitCallbackRegistrar.add("MediaCtrl.Forward", boost::bind(&LLPanelPrimMediaControls::onClickForward, this));
mCommitCallbackRegistrar.add("MediaCtrl.Home", boost::bind(&LLPanelPrimMediaControls::onClickHome, this));
mCommitCallbackRegistrar.add("MediaCtrl.Stop", boost::bind(&LLPanelPrimMediaControls::onClickStop, this));
mCommitCallbackRegistrar.add("MediaCtrl.MediaStop", boost::bind(&LLPanelPrimMediaControls::onClickMediaStop, this));
mCommitCallbackRegistrar.add("MediaCtrl.Reload", boost::bind(&LLPanelPrimMediaControls::onClickReload, this));
mCommitCallbackRegistrar.add("MediaCtrl.Play", boost::bind(&LLPanelPrimMediaControls::onClickPlay, this));
mCommitCallbackRegistrar.add("MediaCtrl.Pause", boost::bind(&LLPanelPrimMediaControls::onClickPause, this));
@ -149,6 +151,7 @@ BOOL LLPanelPrimMediaControls::postBuild()
mLeftBookend = getChild<LLUICtrl>("left_bookend");
mRightBookend = getChild<LLUICtrl>("right_bookend");
mBackgroundImage = LLUI::getUIImage(getString("control_background_image_name"));
LLStringUtil::convertToF32(getString("skip_step"), mSkipStep);
// These are currently removed...but getChild creates a "dummy" widget.
// This class handles them missing.
@ -873,6 +876,18 @@ void LLPanelPrimMediaControls::onClickStop()
LLViewerMediaImpl* impl = getTargetMediaImpl();
if(impl)
{
impl->navigateStop();
}
}
void LLPanelPrimMediaControls::onClickMediaStop()
{
focusOnTarget();
LLViewerMediaImpl* impl = getTargetMediaImpl();
if(impl)
{
impl->stop();
@ -887,8 +902,7 @@ void LLPanelPrimMediaControls::onClickSkipBack()
if (impl)
{
// XXX Oddly, the impl has the policy that "skipping" is really navigating
impl->navigateBack();
impl->skipBack(mSkipStep);
}
}
@ -900,8 +914,7 @@ void LLPanelPrimMediaControls::onClickSkipForward()
if (impl)
{
// XXX Oddly, the impl has the policy that "skipping" is really navigating
impl->navigateForward();
impl->skipForward(mSkipStep);
}
}

View File

@ -97,6 +97,7 @@ private:
void onClickZoom();
void onClickSkipBack();
void onClickSkipForward();
void onClickMediaStop();
void onCommitURL();
void updateZoom();
@ -158,6 +159,7 @@ private:
LLUICtrl *mLeftBookend;
LLUICtrl *mRightBookend;
LLUIImage* mBackgroundImage;
F32 mSkipStep;
LLUICtrl *mMediaPanelScroll;
LLButton *mScrollUpCtrl;

View File

@ -278,7 +278,7 @@ viewer_media_t LLViewerMedia::newMediaImpl(
}
else
{
media_impl->stop();
media_impl->unload();
media_impl->mTextureId = texture_id;
media_impl->mMediaWidth = media_width;
media_impl->mMediaHeight = media_height;
@ -1092,15 +1092,7 @@ void LLViewerMediaImpl::stop()
{
if(mMediaSource)
{
if(mMediaSource->pluginSupportsMediaBrowser())
{
mMediaSource->browse_stop();
}
else
{
mMediaSource->stop();
}
mMediaSource->stop();
// destroyMediaSource();
}
}
@ -1132,6 +1124,40 @@ void LLViewerMediaImpl::seek(F32 time)
}
}
//////////////////////////////////////////////////////////////////////////////////////////
void LLViewerMediaImpl::skipBack(F32 step_scale)
{
if(mMediaSource)
{
if(mMediaSource->pluginSupportsMediaTime())
{
F64 back_step = mMediaSource->getCurrentTime() - (mMediaSource->getDuration()*step_scale);
if(back_step < 0.0)
{
back_step = 0.0;
}
mMediaSource->seek(back_step);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////
void LLViewerMediaImpl::skipForward(F32 step_scale)
{
if(mMediaSource)
{
if(mMediaSource->pluginSupportsMediaTime())
{
F64 forward_step = mMediaSource->getCurrentTime() + (mMediaSource->getDuration()*step_scale);
if(forward_step > mMediaSource->getDuration())
{
forward_step = mMediaSource->getDuration();
}
mMediaSource->seek(forward_step);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////
void LLViewerMediaImpl::setVolume(F32 volume)
{
@ -1339,21 +1365,7 @@ void LLViewerMediaImpl::navigateBack()
{
if (mMediaSource)
{
if(mMediaSource->pluginSupportsMediaTime())
{
F64 step_scale = 0.02; // temp , can be changed
F64 back_step = mMediaSource->getCurrentTime() - (mMediaSource->getDuration()*step_scale);
if(back_step < 0.0)
{
back_step = 0.0;
}
mMediaSource->seek(back_step);
//mMediaSource->start(-2.0);
}
else
{
mMediaSource->browse_back();
}
mMediaSource->browse_back();
}
}
@ -1362,21 +1374,7 @@ void LLViewerMediaImpl::navigateForward()
{
if (mMediaSource)
{
if(mMediaSource->pluginSupportsMediaTime())
{
F64 step_scale = 0.02; // temp , can be changed
F64 forward_step = mMediaSource->getCurrentTime() + (mMediaSource->getDuration()*step_scale);
if(forward_step > mMediaSource->getDuration())
{
forward_step = mMediaSource->getDuration();
}
mMediaSource->seek(forward_step);
//mMediaSource->start(2.0);
}
else
{
mMediaSource->browse_forward();
}
mMediaSource->browse_forward();
}
}
@ -1525,7 +1523,6 @@ void LLViewerMediaImpl::navigateStop()
{
mMediaSource->browse_stop();
}
}
//////////////////////////////////////////////////////////////////////////////////////////

View File

@ -149,6 +149,8 @@ public:
void pause();
void start();
void seek(F32 time);
void skipBack(F32 step_scale);
void skipForward(F32 step_scale);
void setVolume(F32 volume);
void updateVolume();
F32 getVolume();

View File

@ -218,7 +218,7 @@ void LLViewerParcelMedia::play(LLParcel* parcel)
LL_DEBUGS("Media") << "new media impl with mime type " << mime_type << ", url " << media_url << LL_ENDL;
// Delete the old one first so they don't fight over the texture.
sMediaImpl->stop();
sMediaImpl->unload();
sMediaImpl = LLViewerMedia::newMediaImpl(
placeholder_texture_id,
@ -261,8 +261,7 @@ void LLViewerParcelMedia::stop()
// We need to remove the media HUD if it is up.
LLViewerMediaFocus::getInstance()->clearFocus();
// This will kill the media instance.
sMediaImpl->stop();
// This will unload & kill the media instance.
sMediaImpl = NULL;
}

View File

@ -8,6 +8,7 @@
mouse_opaque="false"
width="800">
<string name="control_background_image_name">Inspector_Background</string>
<string name="skip_step">0.2</string>
<panel
name="media_region"
bottom="125"
@ -165,7 +166,7 @@
min_width="22"
width="22">
<button.commit_callback
function="MediaCtrl.Stop" />
function="MediaCtrl.MediaStop" />
</button>
</layout_panel>
<layout_panel