From 6be6f488ba500fde5706099ccf4e1cfc6473f7fe Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 11 Jul 2013 20:53:12 -0500 Subject: [PATCH] Added setting to toggle autoplaying of prim media, independent of parcel media. Audio autoplay also now yieds to sounds being stopped via nearby media panel. --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llpanelnearbymedia.cpp | 17 ++++++++++++----- indra/newview/llpanelnearbymedia.h | 5 +++++ indra/newview/llviewermedia.cpp | 19 +++++++++++++++---- indra/newview/llviewermedia.h | 1 + indra/newview/llviewermediafocus.cpp | 2 +- indra/newview/llviewerparcelmgr.cpp | 17 ++++++++++++++++- .../xui/en-us/panel_preferences_audio.xml | 13 +++++++------ 8 files changed, 68 insertions(+), 17 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 95f2971b9..ae097df9c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10432,6 +10432,17 @@ This should be as low as possible, but too low may break functionality Value 0 + PrimMediaAutoPlayEnable + + Comment + Auto play prim media when available + Persist + 1 + Type + Boolean + Value + 0 + PerAccountSettingsFile Comment diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 9438dfa79..e2856ae1f 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -84,10 +84,11 @@ LLPanelNearByMedia::LLPanelNearByMedia(bool standalone_panel) { mHoverTimer.stop(); - mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) && - gSavedSettings.getBOOL("MediaTentativeAutoPlay"); + mParcelAudioAutoStart = gSavedSettings.getBOOL("MediaTentativeAutoPlay"); + /*gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) && + gSavedSettings.getBOOL("MediaTentativeAutoPlay");*/ - gSavedSettings.getControl(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING)->getSignal()->connect(boost::bind(&LLPanelNearByMedia::handleMediaAutoPlayChanged, this, _2)); + //gSavedSettings.getControl(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING)->getSignal()->connect(boost::bind(&LLPanelNearByMedia::handleMediaAutoPlayChanged, this, _2)); mCommitCallbackRegistrar.add("MediaListCtrl.EnableAll", boost::bind(&LLPanelNearByMedia::onClickEnableAll, this)); mCommitCallbackRegistrar.add("MediaListCtrl.DisableAll", boost::bind(&LLPanelNearByMedia::onClickDisableAll, this)); @@ -909,7 +910,7 @@ void LLPanelNearByMedia::onClickParcelAudioPlay() } else { - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + LLViewerParcelMedia::playStreamingMusic(LLViewerParcelMgr::getInstance()->getAgentParcel()); } } @@ -1263,12 +1264,18 @@ void* createNearbyMediaPanel(void* userdata) return new LLPanelNearByMedia(false); } -LLFloaterNearbyMedia::LLFloaterNearbyMedia() +LLFloaterNearbyMedia::LLFloaterNearbyMedia() : mPanel(NULL) { mFactoryMap["nearby_media"] = LLCallbackMap(createNearbyMediaPanel, this); LLUICtrlFactory::getInstance()->buildFloater(this,"floater_nearby_media.xml",&mFactoryMap,false); } +/*virtual*/ BOOL LLFloaterNearbyMedia::postBuild() +{ + mPanel = getChild("nearby_media",false,false); + return LLFloater::postBuild(); +} + // static void LLFloaterNearbyMedia::updateClass() { diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h index e6d0a4d9b..410dfb48c 100644 --- a/indra/newview/llpanelnearbymedia.h +++ b/indra/newview/llpanelnearbymedia.h @@ -189,10 +189,15 @@ public: static void updateClass(); + /*virtual*/ BOOL postBuild(); /*virtual*/ void onClose(bool app_quitting); /*virtual*/ void onOpen(); virtual void handleReshape(const LLRect& new_rect, bool by_user); + + LLPanelNearByMedia* getMediaPanel() { return mPanel; } +private: + LLPanelNearByMedia* mPanel; }; #endif // LL_LLPANELNEARBYMEDIA_H diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index ee4162dce..0072b68fc 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -87,6 +87,7 @@ std::string getProfileURL(const std::string& agent_name); /*static*/ const char* LLViewerMedia::AUTO_PLAY_MEDIA_SETTING = "ParcelMediaAutoPlayEnable"; +/*static*/ const char* LLViewerMedia::AUTO_PLAY_PRIM_MEDIA_SETTING = "PrimMediaAutoPlayEnable"; /*static*/ const char* LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING = "MediaShowOnOthers"; /*static*/ const char* LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING = "MediaShowWithinParcel"; /*static*/ const char* LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING = "MediaShowOutsideParcel"; @@ -1103,7 +1104,7 @@ void LLViewerMedia::setAllMediaEnabled(bool val) } else { - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + LLViewerParcelMedia::playStreamingMusic(LLViewerParcelMgr::getInstance()->getAgentParcel()); } } } @@ -3857,9 +3858,19 @@ void LLViewerMediaImpl::setTextureID(LLUUID id) // bool LLViewerMediaImpl::isAutoPlayable() const { - return (mMediaAutoPlay && - gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) && - gSavedSettings.getBOOL("MediaTentativeAutoPlay")); + static const LLCachedControl media_tentative_auto_play("MediaTentativeAutoPlay",false); + static const LLCachedControl auto_play_parcel_media(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING,false); + static const LLCachedControl auto_play_prim_media(LLViewerMedia::AUTO_PLAY_PRIM_MEDIA_SETTING,false); + if(mMediaAutoPlay && media_tentative_auto_play) + { + if(getUsedInUI()) + return true; + else if(isParcelMedia() && auto_play_parcel_media) + return true; + else if(auto_play_prim_media) + return true; + } + return false; } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 8be43590c..902d7ae0f 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -84,6 +84,7 @@ public: // String to get/set media autoplay in gSavedSettings static const char* AUTO_PLAY_MEDIA_SETTING; + static const char* AUTO_PLAY_PRIM_MEDIA_SETTING; static const char* SHOW_MEDIA_ON_OTHERS_SETTING; static const char* SHOW_MEDIA_WITHIN_PARCEL_SETTING; static const char* SHOW_MEDIA_OUTSIDE_PARCEL_SETTING; diff --git a/indra/newview/llviewermediafocus.cpp b/indra/newview/llviewermediafocus.cpp index 701d4981b..91a2dfafc 100644 --- a/indra/newview/llviewermediafocus.cpp +++ b/indra/newview/llviewermediafocus.cpp @@ -414,7 +414,7 @@ void LLViewerMediaFocus::update() normal = mHoverObjectNormal; } - if(media_impl && viewer_object) + if(media_impl && viewer_object && !media_impl->isForcedUnloaded()) { // We have an object and impl to point at. diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 2a42b7661..5b7c7f274 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -55,6 +55,7 @@ #include "llfloaterbuyland.h" #include "llfloatergroups.h" //#include "llfloaterhtml.h" +#include "llpanelnearbymedia.h" #include "llfloatersellland.h" #include "llfloaterteleporthistory.h" #include "llfloatertools.h" @@ -1799,6 +1800,9 @@ void optionally_start_music(LLParcel* parcel) { if (gSavedSettings.getBOOL("AudioStreamingMusic")) { + + + // Make the user click the start button on the overlay bar. JC // llinfos << "Starting parcel music " << parcel->getMusicURL() << llendl; @@ -1806,8 +1810,19 @@ void optionally_start_music(LLParcel* parcel) // changed as part of SL-4878 if (gOverlayBar && gOverlayBar->musicPlaying()) { - LLViewerParcelMedia::playStreamingMusic(parcel); + LLPanelNearByMedia* nearby_media_panel = LLFloaterNearbyMedia::instanceExists() ? LLFloaterNearbyMedia::getInstance()->getMediaPanel() : NULL; + if ((nearby_media_panel && + nearby_media_panel->getParcelAudioAutoStart()) || + // or they have expressed no opinion in the UI, but have autoplay on... + (!nearby_media_panel && + /*gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) &&*/ + gSavedSettings.getBOOL("MediaTentativeAutoPlay"))) + { + LLViewerParcelMedia::playStreamingMusic(parcel); + return; + } } + gAudiop->startInternetStream(LLStringUtil::null); } } diff --git a/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml b/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml index 727e05255..3f77ee5e2 100644 --- a/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml +++ b/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml @@ -1,13 +1,14 @@ Volume: - Streaming Preferences: - Audio Preferences: - - + Streaming Preferences: + Audio Preferences: + + + - - + +