diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lloverlaybar.cpp | 453 |
1 files changed, 250 insertions, 203 deletions
diff --git a/linden/indra/newview/lloverlaybar.cpp b/linden/indra/newview/lloverlaybar.cpp index 401cb02..f5addd0 100644 --- a/linden/indra/newview/lloverlaybar.cpp +++ b/linden/indra/newview/lloverlaybar.cpp | |||
@@ -34,24 +34,26 @@ | |||
34 | #include "lloverlaybar.h" | 34 | #include "lloverlaybar.h" |
35 | 35 | ||
36 | #include "audioengine.h" | 36 | #include "audioengine.h" |
37 | #include "llparcel.h" | ||
38 | |||
39 | #include "llagent.h" | 37 | #include "llagent.h" |
40 | #include "llbutton.h" | 38 | #include "llbutton.h" |
41 | #include "llviewercontrol.h" | 39 | #include "llfocusmgr.h" |
42 | #include "llimview.h" | 40 | #include "llimview.h" |
43 | #include "lltextbox.h" | ||
44 | #include "llvoavatar.h" | ||
45 | #include "llmediaengine.h" | 41 | #include "llmediaengine.h" |
46 | #include "viewer.h" | 42 | #include "llpanelaudiovolume.h" |
43 | #include "llparcel.h" | ||
44 | #include "lltextbox.h" | ||
47 | #include "llui.h" | 45 | #include "llui.h" |
46 | #include "llviewercontrol.h" | ||
47 | #include "llviewerimagelist.h" | ||
48 | #include "llviewermenu.h" // handle_reset_view() | 48 | #include "llviewermenu.h" // handle_reset_view() |
49 | #include "llviewerparcelmgr.h" | 49 | #include "llviewerparcelmgr.h" |
50 | #include "llwebbrowserctrl.h" | ||
51 | #include "llvieweruictrlfactory.h" | 50 | #include "llvieweruictrlfactory.h" |
52 | #include "llviewerimagelist.h" | ||
53 | #include "llviewerwindow.h" | 51 | #include "llviewerwindow.h" |
54 | #include "llfocusmgr.h" | 52 | #include "llvoiceclient.h" |
53 | #include "llvoavatar.h" | ||
54 | #include "llvoiceremotectrl.h" | ||
55 | #include "llwebbrowserctrl.h" | ||
56 | #include "viewer.h" | ||
55 | 57 | ||
56 | // | 58 | // |
57 | // Globals | 59 | // Globals |
@@ -67,38 +69,54 @@ extern S32 MENU_BAR_HEIGHT; | |||
67 | 69 | ||
68 | 70 | ||
69 | //static | 71 | //static |
70 | void* LLOverlayBar::createMediaRemote(void* userdata) | 72 | void* LLOverlayBar::createMasterRemote(void* userdata) |
71 | { | 73 | { |
72 | 74 | LLOverlayBar *self = (LLOverlayBar*)userdata; | |
73 | LLOverlayBar *self = (LLOverlayBar*)userdata; | 75 | self->mMasterRemote = new LLMediaRemoteCtrl ( "master_volume", |
76 | "volume", | ||
77 | LLRect(), | ||
78 | "panel_master_volume.xml"); | ||
79 | return self->mMasterRemote; | ||
80 | } | ||
74 | 81 | ||
75 | 82 | void* LLOverlayBar::createMediaRemote(void* userdata) | |
83 | { | ||
84 | LLOverlayBar *self = (LLOverlayBar*)userdata; | ||
76 | self->mMediaRemote = new LLMediaRemoteCtrl ( "media_remote", | 85 | self->mMediaRemote = new LLMediaRemoteCtrl ( "media_remote", |
77 | "media", | 86 | "media", |
78 | LLRect(), | 87 | LLRect(), |
79 | "panel_media_remote.xml"); | 88 | "panel_media_remote.xml"); |
80 | return self->mMediaRemote; | 89 | return self->mMediaRemote; |
81 | } | 90 | } |
82 | 91 | ||
83 | |||
84 | |||
85 | void* LLOverlayBar::createMusicRemote(void* userdata) | 92 | void* LLOverlayBar::createMusicRemote(void* userdata) |
86 | { | 93 | { |
87 | |||
88 | LLOverlayBar *self = (LLOverlayBar*)userdata; | 94 | LLOverlayBar *self = (LLOverlayBar*)userdata; |
89 | |||
90 | self->mMusicRemote = new LLMediaRemoteCtrl ( "music_remote", | 95 | self->mMusicRemote = new LLMediaRemoteCtrl ( "music_remote", |
91 | "music", | 96 | "music", |
92 | LLRect(), | 97 | LLRect(), |
93 | "panel_music_remote.xml" ); | 98 | "panel_music_remote.xml" ); |
94 | return self->mMusicRemote; | 99 | return self->mMusicRemote; |
95 | } | 100 | } |
96 | 101 | ||
102 | void* LLOverlayBar::createVoiceRemote(void* userdata) | ||
103 | { | ||
104 | LLOverlayBar *self = (LLOverlayBar*)userdata; | ||
105 | self->mVoiceRemote = new LLVoiceRemoteCtrl("voice_remote"); | ||
106 | return self->mVoiceRemote; | ||
107 | } | ||
108 | |||
97 | 109 | ||
98 | 110 | ||
99 | 111 | ||
100 | LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect) | 112 | LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect) |
101 | : LLPanel(name, rect, FALSE) // not bordered | 113 | : LLPanel(name, rect, FALSE), // not bordered |
114 | mMasterRemote(NULL), | ||
115 | mMusicRemote(NULL), | ||
116 | mMediaRemote(NULL), | ||
117 | mVoiceRemote(NULL), | ||
118 | mMediaState(STOPPED), | ||
119 | mMusicState(STOPPED) | ||
102 | { | 120 | { |
103 | setMouseOpaque(FALSE); | 121 | setMouseOpaque(FALSE); |
104 | setIsChrome(TRUE); | 122 | setIsChrome(TRUE); |
@@ -106,8 +124,10 @@ LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect) | |||
106 | isBuilt = FALSE; | 124 | isBuilt = FALSE; |
107 | 125 | ||
108 | LLCallbackMap::map_t factory_map; | 126 | LLCallbackMap::map_t factory_map; |
127 | factory_map["master_volume"] = LLCallbackMap(LLOverlayBar::createMasterRemote, this); | ||
109 | factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this); | 128 | factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this); |
110 | factory_map["music_remote"] = LLCallbackMap(LLOverlayBar::createMusicRemote, this); | 129 | factory_map["music_remote"] = LLCallbackMap(LLOverlayBar::createMusicRemote, this); |
130 | factory_map["voice_remote"] = LLCallbackMap(LLOverlayBar::createVoiceRemote, this); | ||
111 | 131 | ||
112 | gUICtrlFactory->buildPanel(this, "panel_overlaybar.xml", &factory_map); | 132 | gUICtrlFactory->buildPanel(this, "panel_overlaybar.xml", &factory_map); |
113 | 133 | ||
@@ -117,30 +137,17 @@ LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect) | |||
117 | childSetAction("Mouselook",onClickMouselook,this); | 137 | childSetAction("Mouselook",onClickMouselook,this); |
118 | childSetAction("Stand Up",onClickStandUp,this); | 138 | childSetAction("Stand Up",onClickStandUp,this); |
119 | 139 | ||
120 | mMusicRemote->addObserver ( this ); | ||
121 | |||
122 | if ( gAudiop ) | ||
123 | { | ||
124 | mMusicRemote->setVolume ( gSavedSettings.getF32 ( "AudioLevelMusic" ) ); | ||
125 | mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE ); | ||
126 | }; | ||
127 | |||
128 | mIsFocusRoot = TRUE; | 140 | mIsFocusRoot = TRUE; |
129 | |||
130 | mMediaRemote->addObserver ( this ); | ||
131 | mMediaRemote->setVolume ( gSavedSettings.getF32 ( "MediaAudioVolume" ) ); | ||
132 | |||
133 | isBuilt = true; | 141 | isBuilt = true; |
134 | 142 | ||
143 | // make overlay bar conform to window size | ||
144 | setRect(rect); | ||
135 | layoutButtons(); | 145 | layoutButtons(); |
136 | } | 146 | } |
137 | 147 | ||
138 | LLOverlayBar::~LLOverlayBar() | 148 | LLOverlayBar::~LLOverlayBar() |
139 | { | 149 | { |
140 | // LLView destructor cleans up children | 150 | // LLView destructor cleans up children |
141 | |||
142 | mMusicRemote->remObserver ( this ); | ||
143 | mMediaRemote->remObserver ( this ); | ||
144 | } | 151 | } |
145 | 152 | ||
146 | EWidgetType LLOverlayBar::getWidgetType() const | 153 | EWidgetType LLOverlayBar::getWidgetType() const |
@@ -164,20 +171,28 @@ void LLOverlayBar::reshape(S32 width, S32 height, BOOL called_from_parent) | |||
164 | } | 171 | } |
165 | } | 172 | } |
166 | 173 | ||
167 | |||
168 | void LLOverlayBar::layoutButtons() | 174 | void LLOverlayBar::layoutButtons() |
169 | { | 175 | { |
170 | S32 width = mRect.getWidth(); | 176 | S32 width = mRect.getWidth(); |
171 | if (width > 800) width = 800; | 177 | if (width > 1024) width = 1024; |
172 | 178 | ||
173 | S32 count = getChildCount(); | 179 | S32 count = getChildCount(); |
174 | const S32 PAD = gSavedSettings.getS32("StatusBarPad"); | 180 | const S32 PAD = gSavedSettings.getS32("StatusBarPad"); |
175 | 181 | ||
176 | F32 segment_width = (F32)(width) / (F32)count; | 182 | const S32 num_media_controls = 3; |
183 | S32 media_remote_width = mMediaRemote ? mMediaRemote->getRect().getWidth() : 0; | ||
184 | S32 music_remote_width = mMusicRemote ? mMusicRemote->getRect().getWidth() : 0; | ||
185 | S32 voice_remote_width = mVoiceRemote ? mVoiceRemote->getRect().getWidth() : 0; | ||
186 | S32 master_remote_width = mMasterRemote ? mMasterRemote->getRect().getWidth() : 0; | ||
177 | 187 | ||
178 | S32 btn_width = lltrunc(segment_width - PAD); | 188 | // total reserved width for all media remotes |
189 | const S32 ENDPAD = 20; | ||
190 | S32 remote_total_width = media_remote_width + PAD + music_remote_width + PAD + voice_remote_width + PAD + master_remote_width + ENDPAD; | ||
179 | 191 | ||
180 | S32 remote_width = mMusicRemote->getRect().getWidth(); | 192 | // calculate button widths |
193 | F32 segment_width = (F32)(width - remote_total_width) / (F32)(count - num_media_controls); | ||
194 | |||
195 | S32 btn_width = lltrunc(segment_width - PAD); | ||
181 | 196 | ||
182 | // Evenly space all views | 197 | // Evenly space all views |
183 | LLRect r; | 198 | LLRect r; |
@@ -187,22 +202,47 @@ void LLOverlayBar::layoutButtons() | |||
187 | { | 202 | { |
188 | LLView *view = *child_iter; | 203 | LLView *view = *child_iter; |
189 | r = view->getRect(); | 204 | r = view->getRect(); |
190 | r.mLeft = (width) - llround((i+1)*segment_width); | 205 | r.mLeft = (width) - llround(remote_total_width + (i-num_media_controls+1)*segment_width); |
191 | r.mRight = r.mLeft + btn_width; | 206 | r.mRight = r.mLeft + btn_width; |
192 | view->setRect(r); | 207 | view->setRect(r); |
193 | i++; | 208 | i++; |
194 | } | 209 | } |
195 | 210 | ||
196 | // Fix up remotes to have constant width because they can't shrink | 211 | // Fix up remotes to have constant width because they can't shrink |
197 | r = mMusicRemote->getRect(); | 212 | S32 right = mRect.getWidth() - remote_total_width - PAD; |
198 | r.mRight = r.mLeft + remote_width; | 213 | if (mMediaRemote) |
199 | mMusicRemote->setRect(r); | 214 | { |
200 | 215 | r = mMediaRemote->getRect(); | |
201 | r = mMediaRemote->getRect(); | 216 | r.mLeft = right + PAD; |
202 | r.mLeft = mMusicRemote->getRect().mRight + PAD; | 217 | right = r.mLeft + media_remote_width; |
203 | r.mRight = r.mLeft + remote_width; | 218 | r.mRight = right; |
204 | mMediaRemote->setRect(r); | 219 | mMediaRemote->setRect(r); |
205 | 220 | } | |
221 | if (mMusicRemote) | ||
222 | { | ||
223 | r = mMusicRemote->getRect(); | ||
224 | r.mLeft = right + PAD; | ||
225 | right = r.mLeft + music_remote_width; | ||
226 | r.mRight = right; | ||
227 | mMusicRemote->setRect(r); | ||
228 | } | ||
229 | if (mVoiceRemote) | ||
230 | { | ||
231 | r = mVoiceRemote->getRect(); | ||
232 | r.mLeft = right + PAD; | ||
233 | right = r.mLeft + voice_remote_width; | ||
234 | r.mRight = right; | ||
235 | mVoiceRemote->setRect(r); | ||
236 | } | ||
237 | if (mMasterRemote) | ||
238 | { | ||
239 | r = mMasterRemote->getRect(); | ||
240 | r.mLeft = right + PAD; | ||
241 | right = r.mLeft + master_remote_width; | ||
242 | r.mRight = right; | ||
243 | mMasterRemote->setRect(r); | ||
244 | } | ||
245 | |||
206 | updateRect(); | 246 | updateRect(); |
207 | } | 247 | } |
208 | 248 | ||
@@ -282,7 +322,7 @@ void LLOverlayBar::draw() | |||
282 | // Per-frame updates of visibility | 322 | // Per-frame updates of visibility |
283 | void LLOverlayBar::refresh() | 323 | void LLOverlayBar::refresh() |
284 | { | 324 | { |
285 | BOOL im_received = gIMView->getIMReceived(); | 325 | BOOL im_received = gIMMgr->getIMReceived(); |
286 | childSetVisible("IM Received", im_received); | 326 | childSetVisible("IM Received", im_received); |
287 | childSetEnabled("IM Received", im_received); | 327 | childSetEnabled("IM Received", im_received); |
288 | 328 | ||
@@ -313,10 +353,10 @@ void LLOverlayBar::refresh() | |||
313 | 353 | ||
314 | } | 354 | } |
315 | 355 | ||
316 | if ( gAudiop ) | 356 | if ( mMusicRemote && gAudiop ) |
317 | { | 357 | { |
318 | LLParcel* parcel = gParcelMgr->getAgentParcel(); | 358 | LLParcel* parcel = gParcelMgr->getAgentParcel(); |
319 | if (!parcel | 359 | if (!parcel |
320 | || !parcel->getMusicURL() | 360 | || !parcel->getMusicURL() |
321 | || !parcel->getMusicURL()[0] | 361 | || !parcel->getMusicURL()[0] |
322 | || !gSavedSettings.getBOOL("AudioStreamingMusic")) | 362 | || !gSavedSettings.getBOOL("AudioStreamingMusic")) |
@@ -332,50 +372,29 @@ void LLOverlayBar::refresh() | |||
332 | } | 372 | } |
333 | 373 | ||
334 | // if there is a url and a texture and media is enabled and available and media streaming is on... (phew!) | 374 | // if there is a url and a texture and media is enabled and available and media streaming is on... (phew!) |
335 | if ( LLMediaEngine::getInstance () && | 375 | if ( mMediaRemote ) |
336 | LLMediaEngine::getInstance ()->getUrl ().length () && | ||
337 | LLMediaEngine::getInstance ()->getImageUUID ().notNull () && | ||
338 | LLMediaEngine::getInstance ()->isEnabled () && | ||
339 | LLMediaEngine::getInstance ()->isAvailable () && | ||
340 | gSavedSettings.getBOOL ( "AudioStreamingVideo" ) ) | ||
341 | { | 376 | { |
342 | // display remote control | 377 | if (LLMediaEngine::getInstance () && |
343 | mMediaRemote->setVisible ( TRUE ); | 378 | LLMediaEngine::getInstance ()->getUrl ().length () && |
344 | mMediaRemote->setEnabled ( TRUE ); | 379 | LLMediaEngine::getInstance ()->getImageUUID ().notNull () && |
345 | 380 | LLMediaEngine::getInstance ()->isEnabled () && | |
346 | if ( LLMediaEngine::getInstance ()->getMediaRenderer () ) | 381 | LLMediaEngine::getInstance ()->isAvailable () && |
382 | gSavedSettings.getBOOL ( "AudioStreamingVideo" ) ) | ||
347 | { | 383 | { |
348 | if ( LLMediaEngine::getInstance ()->getMediaRenderer ()->isPlaying () || | 384 | // display remote control |
349 | LLMediaEngine::getInstance ()->getMediaRenderer ()->isLooping () ) | 385 | mMediaRemote->setVisible ( TRUE ); |
350 | { | 386 | mMediaRemote->setEnabled ( TRUE ); |
351 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Pause, TRUE ); | 387 | } |
352 | } | 388 | else |
353 | else | 389 | { |
354 | if ( LLMediaEngine::getInstance ()->getMediaRenderer ()->isPaused () ) | 390 | mMediaRemote->setVisible ( FALSE ); |
355 | { | 391 | mMediaRemote->setEnabled ( FALSE ); |
356 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Play, TRUE ); | 392 | } |
357 | } | ||
358 | else | ||
359 | { | ||
360 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Stop, TRUE ); | ||
361 | }; | ||
362 | }; | ||
363 | } | 393 | } |
364 | else | 394 | if (mVoiceRemote) |
365 | { | 395 | { |
366 | mMediaRemote->setVisible ( FALSE ); | 396 | mVoiceRemote->setVisible(LLVoiceClient::voiceEnabled()); |
367 | mMediaRemote->setEnabled ( FALSE ); | 397 | } |
368 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Stop, TRUE ); | ||
369 | }; | ||
370 | |||
371 | BOOL any_button = (childIsVisible("IM Received") | ||
372 | || childIsVisible("Set Not Busy") | ||
373 | || childIsVisible("Release Keys") | ||
374 | || childIsVisible("Mouselook") | ||
375 | || childIsVisible("Stand Up") | ||
376 | || mMusicRemote->getVisible() | ||
377 | || mMediaRemote->getVisible() ); | ||
378 | |||
379 | 398 | ||
380 | // turn off the whole bar in mouselook | 399 | // turn off the whole bar in mouselook |
381 | if (gAgent.cameraMouselook()) | 400 | if (gAgent.cameraMouselook()) |
@@ -384,8 +403,8 @@ void LLOverlayBar::refresh() | |||
384 | } | 403 | } |
385 | else | 404 | else |
386 | { | 405 | { |
387 | setVisible(any_button); | 406 | setVisible(TRUE); |
388 | }; | 407 | } |
389 | } | 408 | } |
390 | 409 | ||
391 | //----------------------------------------------------------------------- | 410 | //----------------------------------------------------------------------- |
@@ -395,7 +414,7 @@ void LLOverlayBar::refresh() | |||
395 | // static | 414 | // static |
396 | void LLOverlayBar::onClickIMReceived(void*) | 415 | void LLOverlayBar::onClickIMReceived(void*) |
397 | { | 416 | { |
398 | gIMView->setFloaterOpen(TRUE); | 417 | gIMMgr->setFloaterOpen(TRUE); |
399 | } | 418 | } |
400 | 419 | ||
401 | 420 | ||
@@ -431,134 +450,162 @@ void LLOverlayBar::onClickStandUp(void*) | |||
431 | } | 450 | } |
432 | 451 | ||
433 | //////////////////////////////////////////////////////////////////////////////// | 452 | //////////////////////////////////////////////////////////////////////////////// |
434 | // | 453 | // static media helpers |
435 | // | 454 | // *TODO: Move this into an audio manager abstraction |
436 | void | ||
437 | LLOverlayBar:: | ||
438 | onVolumeChange ( const LLMediaRemoteCtrlObserver::EventType& eventIn ) | ||
439 | { | ||
440 | LLUICtrl* control = eventIn.getControl (); | ||
441 | F32 value = eventIn.getValue (); | ||
442 | 455 | ||
443 | if ( control == mMusicRemote ) | 456 | //static |
457 | void LLOverlayBar::mediaPlay(void*) | ||
458 | { | ||
459 | if (!gOverlayBar) | ||
444 | { | 460 | { |
445 | if (gAudiop) | 461 | return; |
446 | { | ||
447 | gAudiop->setInternetStreamGain ( value ); | ||
448 | }; | ||
449 | gSavedSettings.setF32 ( "AudioLevelMusic", value ); | ||
450 | } | 462 | } |
451 | else | 463 | gOverlayBar->mMediaState = PLAYING; // desired state |
452 | if ( control == mMediaRemote ) | 464 | LLParcel* parcel = gParcelMgr->getAgentParcel(); |
465 | if (parcel) | ||
453 | { | 466 | { |
454 | LLMediaEngine::getInstance ()->setVolume ( value ); | 467 | LLString path(""); |
455 | gSavedSettings.setF32 ( "MediaAudioVolume", value ); | 468 | LLMediaEngine::getInstance()->convertImageAndLoadUrl( true, false, path ); |
456 | 469 | } | |
457 | }; | ||
458 | } | 470 | } |
459 | 471 | //static | |
460 | //////////////////////////////////////////////////////////////////////////////// | 472 | void LLOverlayBar::mediaPause(void*) |
461 | // | ||
462 | // | ||
463 | void | ||
464 | LLOverlayBar:: | ||
465 | onStopButtonPressed ( const LLMediaRemoteCtrlObserver::EventType& eventIn ) | ||
466 | { | 473 | { |
467 | LLUICtrl* control = eventIn.getControl (); | 474 | if (!gOverlayBar) |
468 | |||
469 | if ( control == mMusicRemote ) | ||
470 | { | 475 | { |
471 | if ( gAudiop ) | 476 | return; |
472 | { | ||
473 | gAudiop->stopInternetStream (); | ||
474 | }; | ||
475 | mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE ); | ||
476 | } | 477 | } |
477 | else | 478 | gOverlayBar->mMediaState = PAUSED; // desired state |
478 | if ( control == mMediaRemote ) | 479 | LLMediaEngine::getInstance()->pause(); |
480 | } | ||
481 | //static | ||
482 | void LLOverlayBar::mediaStop(void*) | ||
483 | { | ||
484 | if (!gOverlayBar) | ||
479 | { | 485 | { |
480 | LLMediaEngine::getInstance ()->stop (); | 486 | return; |
481 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Stop, TRUE ); | 487 | } |
482 | }; | 488 | gOverlayBar->mMediaState = STOPPED; // desired state |
489 | LLMediaEngine::getInstance()->stop(); | ||
483 | } | 490 | } |
484 | 491 | ||
485 | //////////////////////////////////////////////////////////////////////////////// | 492 | //static |
486 | // | 493 | void LLOverlayBar::musicPlay(void*) |
487 | // | ||
488 | void LLOverlayBar::onPlayButtonPressed( const LLMediaRemoteCtrlObserver::EventType& eventIn ) | ||
489 | { | 494 | { |
490 | LLUICtrl* control = eventIn.getControl (); | 495 | if (!gOverlayBar) |
491 | |||
492 | LLParcel* parcel = gParcelMgr->getAgentParcel(); | ||
493 | if ( control == mMusicRemote ) | ||
494 | { | 496 | { |
495 | if (gAudiop) | 497 | return; |
498 | } | ||
499 | gOverlayBar->mMusicState = PLAYING; // desired state | ||
500 | if (gAudiop) | ||
501 | { | ||
502 | LLParcel* parcel = gParcelMgr->getAgentParcel(); | ||
503 | if ( parcel ) | ||
496 | { | 504 | { |
497 | if ( parcel ) | 505 | // this doesn't work properly when crossing parcel boundaries - even when the |
506 | // stream is stopped, it doesn't return the right thing - commenting out for now. | ||
507 | // if ( gAudiop->isInternetStreamPlaying() == 0 ) | ||
498 | { | 508 | { |
499 | // this doesn't work properly when crossing parcel boundaries - even when the | 509 | gAudiop->startInternetStream(parcel->getMusicURL()); |
500 | // stream is stopped, it doesn't return the right thing - commenting out for now. | ||
501 | //if ( gAudiop->isInternetStreamPlaying() == 0 ) | ||
502 | //{ | ||
503 | const char* music_url = parcel->getMusicURL(); | ||
504 | |||
505 | gAudiop->startInternetStream(music_url); | ||
506 | |||
507 | mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Play, FALSE ); | ||
508 | //} | ||
509 | } | 510 | } |
510 | }; | 511 | } |
511 | |||
512 | // CP: this is the old way of doing things (click play each time on a parcel to start stream) | ||
513 | //if (gAudiop) | ||
514 | //{ | ||
515 | // if (gAudiop->isInternetStreamPlaying() > 0) | ||
516 | // { | ||
517 | // gAudiop->pauseInternetStream ( 0 ); | ||
518 | // } | ||
519 | // else | ||
520 | // { | ||
521 | // if (parcel) | ||
522 | // { | ||
523 | // const char* music_url = parcel->getMusicURL(); | ||
524 | // gAudiop->startInternetStream(music_url); | ||
525 | // } | ||
526 | // } | ||
527 | //}; | ||
528 | //mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE ); | ||
529 | } | 512 | } |
530 | else | 513 | } |
531 | if ( control == mMediaRemote ) | 514 | //static |
515 | void LLOverlayBar::musicPause(void*) | ||
516 | { | ||
517 | if (!gOverlayBar) | ||
532 | { | 518 | { |
533 | LLParcel* parcel = gParcelMgr->getAgentParcel(); | 519 | return; |
534 | if (parcel) | 520 | } |
521 | gOverlayBar->mMusicState = PAUSED; // desired state | ||
522 | if (gAudiop) | ||
523 | { | ||
524 | gAudiop->pauseInternetStream(1); | ||
525 | } | ||
526 | } | ||
527 | //static | ||
528 | void LLOverlayBar::musicStop(void*) | ||
529 | { | ||
530 | if (!gOverlayBar) | ||
531 | { | ||
532 | return; | ||
533 | } | ||
534 | gOverlayBar->mMusicState = STOPPED; // desired state | ||
535 | if (gAudiop) | ||
536 | { | ||
537 | gAudiop->stopInternetStream(); | ||
538 | } | ||
539 | } | ||
540 | |||
541 | //static | ||
542 | void LLOverlayBar::enableMusicButtons(LLPanel* panel) | ||
543 | { | ||
544 | BOOL play_enabled = FALSE; | ||
545 | BOOL play_visible = TRUE; | ||
546 | BOOL pause_visible = FALSE; | ||
547 | BOOL stop_enabled = FALSE; | ||
548 | if ( gAudiop && gOverlayBar && gSavedSettings.getBOOL("AudioStreamingMusic")) | ||
549 | { | ||
550 | play_enabled = TRUE; | ||
551 | S32 is_playing = gAudiop->isInternetStreamPlaying(); | ||
552 | if (is_playing == 1) | ||
535 | { | 553 | { |
536 | LLString path( "" ); | 554 | play_visible = FALSE; |
537 | LLMediaEngine::getInstance ()->convertImageAndLoadUrl( true, false, path ); | 555 | pause_visible = TRUE; |
538 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Play, TRUE ); | 556 | stop_enabled = TRUE; |
539 | } | 557 | } |
540 | }; | 558 | else if (is_playing == 2) |
559 | { | ||
560 | play_visible = TRUE; | ||
561 | pause_visible = FALSE; | ||
562 | stop_enabled = TRUE; | ||
563 | } | ||
564 | } | ||
565 | panel->childSetEnabled("music_play", play_enabled); | ||
566 | panel->childSetEnabled("music_pause", play_enabled); | ||
567 | panel->childSetVisible("music_play", play_visible); | ||
568 | panel->childSetVisible("music_pause", pause_visible); | ||
569 | panel->childSetEnabled("music_stop", stop_enabled); | ||
541 | } | 570 | } |
542 | 571 | ||
543 | //////////////////////////////////////////////////////////////////////////////// | 572 | //static |
544 | // | 573 | void LLOverlayBar::enableMediaButtons(LLPanel* panel) |
545 | // | ||
546 | void LLOverlayBar::onPauseButtonPressed( const LLMediaRemoteCtrlObserver::EventType& eventIn ) | ||
547 | { | 574 | { |
548 | LLUICtrl* control = eventIn.getControl (); | 575 | // Media |
576 | BOOL play_enabled = FALSE; | ||
577 | BOOL play_visible = TRUE; | ||
578 | BOOL pause_visible = FALSE; | ||
579 | BOOL stop_enabled = FALSE; | ||
549 | 580 | ||
550 | if ( control == mMusicRemote ) | 581 | if ( LLMediaEngine::getInstance() && gOverlayBar && gSavedSettings.getBOOL("AudioStreamingVideo") ) |
551 | { | 582 | { |
552 | if (gAudiop) | 583 | play_enabled = TRUE; |
584 | if (LLMediaEngine::getInstance()->getMediaRenderer()) | ||
553 | { | 585 | { |
554 | gAudiop->pauseInternetStream ( 1 ); | 586 | if ( LLMediaEngine::getInstance()->getMediaRenderer()->isPlaying() || |
555 | }; | 587 | LLMediaEngine::getInstance()->getMediaRenderer()->isLooping() ) |
556 | mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Play, FALSE ); | 588 | { |
589 | play_visible = FALSE; | ||
590 | pause_visible = TRUE; | ||
591 | stop_enabled = TRUE; | ||
592 | } | ||
593 | else if ( LLMediaEngine::getInstance()->getMediaRenderer()->isPaused() ) | ||
594 | { | ||
595 | play_visible = TRUE; | ||
596 | pause_visible = FALSE; | ||
597 | stop_enabled = TRUE; | ||
598 | } | ||
599 | } | ||
557 | } | 600 | } |
558 | else | 601 | panel->childSetEnabled("media_play", play_enabled); |
559 | if ( control == mMediaRemote ) | 602 | panel->childSetEnabled("media_pause", play_enabled); |
560 | { | 603 | panel->childSetVisible("media_play", play_visible); |
561 | LLMediaEngine::getInstance ()->pause (); | 604 | panel->childSetVisible("media_pause", pause_visible); |
562 | mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Pause, TRUE ); | 605 | panel->childSetEnabled("media_stop", stop_enabled); |
563 | }; | 606 | } |
607 | |||
608 | void LLOverlayBar::toggleAudioVolumeFloater(void* user_data) | ||
609 | { | ||
610 | LLFloaterAudioVolume::toggleInstance(LLSD()); | ||
564 | } | 611 | } |