aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmediaremotectrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llmediaremotectrl.cpp170
1 files changed, 139 insertions, 31 deletions
diff --git a/linden/indra/newview/llmediaremotectrl.cpp b/linden/indra/newview/llmediaremotectrl.cpp
index 8bf9103..401fc7e 100644
--- a/linden/indra/newview/llmediaremotectrl.cpp
+++ b/linden/indra/newview/llmediaremotectrl.cpp
@@ -33,9 +33,16 @@
33 33
34#include "llmediaremotectrl.h" 34#include "llmediaremotectrl.h"
35 35
36#include "audioengine.h"
37#include "lliconctrl.h"
38#include "llmimetypes.h"
36#include "lloverlaybar.h" 39#include "lloverlaybar.h"
40#include "llviewermedia.h"
41#include "llviewerparcelmedia.h"
42#include "llviewerparcelmgr.h"
37#include "llvieweruictrlfactory.h" 43#include "llvieweruictrlfactory.h"
38#include "llpanelaudiovolume.h" 44#include "llpanelaudiovolume.h"
45#include "llparcel.h"
39#include "llviewercontrol.h" 46#include "llviewercontrol.h"
40#include "llbutton.h" 47#include "llbutton.h"
41 48
@@ -45,7 +52,7 @@
45LLMediaRemoteCtrl::LLMediaRemoteCtrl() 52LLMediaRemoteCtrl::LLMediaRemoteCtrl()
46{ 53{
47 setIsChrome(TRUE); 54 setIsChrome(TRUE);
48 mIsFocusRoot = TRUE; 55 setFocusRoot(TRUE);
49 56
50 mFactoryMap["Volume Panel"] = LLCallbackMap(createVolumePanel, NULL); 57 mFactoryMap["Volume Panel"] = LLCallbackMap(createVolumePanel, NULL);
51 build(); 58 build();
@@ -69,6 +76,10 @@ BOOL LLMediaRemoteCtrl::postBuild()
69{ 76{
70 childSetAction("media_play",LLOverlayBar::toggleMediaPlay,this); 77 childSetAction("media_play",LLOverlayBar::toggleMediaPlay,this);
71 childSetAction("music_play",LLOverlayBar::toggleMusicPlay,this); 78 childSetAction("music_play",LLOverlayBar::toggleMusicPlay,this);
79 childSetAction("media_stop",LLOverlayBar::mediaStop,this);
80 childSetAction("music_stop",LLOverlayBar::toggleMusicPlay,this);
81 childSetAction("media_pause",LLOverlayBar::toggleMediaPlay,this);
82 childSetAction("music_pause",LLOverlayBar::toggleMusicPlay,this);
72 83
73 childSetAction("expand", onClickExpandBtn, this); 84 childSetAction("expand", onClickExpandBtn, this);
74 return TRUE; 85 return TRUE;
@@ -76,36 +87,8 @@ BOOL LLMediaRemoteCtrl::postBuild()
76 87
77void LLMediaRemoteCtrl::draw() 88void LLMediaRemoteCtrl::draw()
78{ 89{
79 LLButton* music_play_btn = LLUICtrlFactory::getButtonByName(this, "music_play"); 90 enableMediaButtons();
80 if (music_play_btn) 91
81 {
82 if (gOverlayBar->musicPlaying())
83 {
84 music_play_btn->setValue(TRUE);
85 music_play_btn->setImageOverlay("icn_music-pause.tga");
86 }
87 else
88 {
89 music_play_btn->setValue(FALSE);
90 music_play_btn->setImageOverlay("icn_music-play.tga");
91 }
92 }
93
94 LLButton* media_play_btn = LLUICtrlFactory::getButtonByName(this, "media_play");
95 if (media_play_btn)
96 {
97 if (gOverlayBar->mediaPlaying())
98 {
99 media_play_btn->setValue(TRUE);
100 media_play_btn->setImageOverlay("icn_media-pause.tga");
101 }
102 else
103 {
104 media_play_btn->setValue(FALSE);
105 media_play_btn->setImageOverlay("icn_media-play.tga");
106 }
107 }
108
109 LLButton* expand_button = LLUICtrlFactory::getButtonByName(this, "expand"); 92 LLButton* expand_button = LLUICtrlFactory::getButtonByName(this, "expand");
110 if (expand_button) 93 if (expand_button)
111 { 94 {
@@ -142,3 +125,128 @@ void* LLMediaRemoteCtrl::createVolumePanel(void* data)
142 LLPanelAudioVolume* panel = new LLPanelAudioVolume(); 125 LLPanelAudioVolume* panel = new LLPanelAudioVolume();
143 return panel; 126 return panel;
144} 127}
128
129// Virtual
130void LLMediaRemoteCtrl::setToolTip(const LLString& msg)
131{
132 LLString mime_type = LLMIMETypes::translate(LLViewerMedia::getMimeType());
133 LLString tool_tip = LLMIMETypes::findToolTip(LLViewerMedia::getMimeType());
134 LLString play_tip = LLMIMETypes::findPlayTip(LLViewerMedia::getMimeType());
135 // childSetToolTip("media_stop", getString("stop_label") + "\n" + tool_tip);
136 childSetToolTip("media_icon", tool_tip);
137 childSetToolTip("media_play", play_tip);
138}
139
140void LLMediaRemoteCtrl::enableMediaButtons()
141{
142 // Media
143 bool play_media_enabled = false;
144 bool stop_media_enabled = false;
145 bool play_music_enabled = false;
146 bool stop_music_enabled = false;
147 bool music_show_pause = false;
148 bool media_show_pause = false;
149 LLColor4 music_icon_color = LLUI::sColorsGroup->getColor( "IconDisabledColor" );
150 LLColor4 media_icon_color = LLUI::sColorsGroup->getColor( "IconDisabledColor" );
151 LLString media_type = "none/none";
152
153 // Put this in xui file
154 LLString media_url = getString("default_tooltip_label");
155 LLParcel* parcel = gParcelMgr->getAgentParcel();
156
157 if (gSavedSettings.getBOOL("AudioStreamingVideo"))
158 {
159 if ( parcel && parcel->getMediaURL()[0])
160 {
161 // Set the tooltip
162 // Put this text into xui file
163 media_url = parcel->getObscureMedia() ? getString("media_hidden_label") : parcel->getMediaURL();
164 media_type = parcel->getMediaType();
165
166 play_media_enabled = true;
167 media_icon_color = LLUI::sColorsGroup->getColor( "IconEnabledColor" );
168
169 LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus();
170 switch(status)
171 {
172 case LLMediaBase::STATUS_STOPPED:
173 case LLMediaBase::STATUS_UNKNOWN:
174 media_show_pause = false;
175 stop_media_enabled = false;
176 break;
177 case LLMediaBase::STATUS_STARTED:
178 case LLMediaBase::STATUS_NAVIGATING:
179 case LLMediaBase::STATUS_RESETTING:
180 // HACK: only show the pause button for movie types
181 media_show_pause = LLMIMETypes::widgetType(parcel->getMediaType()) == "movie" ? true : false;
182 stop_media_enabled = true;
183 play_media_enabled = false;
184 break;
185 case LLMediaBase::STATUS_PAUSED:
186 media_show_pause = false;
187 stop_media_enabled = true;
188 break;
189 default:
190 // inherit defaults above
191 break;
192 }
193 }
194 }
195 if (gSavedSettings.getBOOL("AudioStreamingMusic") && gAudiop)
196 {
197
198 if ( parcel && parcel->getMusicURL()[0])
199 {
200 play_music_enabled = true;
201 music_icon_color = LLUI::sColorsGroup->getColor( "IconEnabledColor" );
202
203 if (gOverlayBar->musicPlaying())
204 {
205 music_show_pause = true;
206 stop_music_enabled = true;
207 }
208 else
209 {
210 music_show_pause = false;
211 stop_music_enabled = false;
212 }
213 }
214 // if no mime type has been set disable play
215 if( LLViewerMedia::getMimeType().empty()
216 || LLViewerMedia::getMimeType() == "none/none")
217 {
218 play_media_enabled = false;
219 stop_media_enabled = false;
220 }
221 }
222 const LLUUID media_icon_id = LLUUID(gViewerArt.findString(LLMIMETypes::findIcon(media_type)));
223 LLButton* music_play_btn = LLUICtrlFactory::getButtonByName(this, "music_play");
224 LLButton* music_stop_btn = LLUICtrlFactory::getButtonByName(this, "music_stop");
225 LLButton* music_pause_btn = LLUICtrlFactory::getButtonByName(this, "music_pause");
226 LLButton* media_play_btn = LLUICtrlFactory::getButtonByName(this, "media_play");
227 LLButton* media_stop_btn = LLUICtrlFactory::getButtonByName(this, "media_stop");
228 LLButton* media_pause_btn = LLUICtrlFactory::getButtonByName(this, "media_pause");
229 LLIconCtrl* media_icon = LLUICtrlFactory::getIconByName(this, "media_icon");
230
231 music_play_btn->setEnabled(play_music_enabled);
232 music_stop_btn->setEnabled(stop_music_enabled);
233 music_pause_btn->setEnabled(music_show_pause);
234 music_pause_btn->setVisible(music_show_pause);
235 music_play_btn->setVisible(! music_show_pause);
236 childSetColor("music_icon", music_icon_color);
237 if(! media_icon_id.isNull())
238 {
239 media_icon->setImage(media_icon_id);
240 }
241
242 media_play_btn->setEnabled(play_media_enabled);
243 media_stop_btn->setEnabled(stop_media_enabled);
244 media_pause_btn->setEnabled(media_show_pause);
245 media_pause_btn->setVisible(media_show_pause);
246 media_play_btn->setVisible(! media_show_pause);
247 childSetColor("media_icon", media_icon_color);
248
249 setToolTip(media_url);
250}
251
252