notifier.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: notifier.m
  4. Version: 1.3
  5. Type: maki/notifier
  6. Date: 14. Mrz. 2007 - 14:50
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. Note: Based on notifier.m from Winamp Modern
  12. -----------------------------------------------------
  13. // Workaround for Winamp bug by Pieter Nieuwoudt (pjn123) - [email protected] \\
  14. Temparary fix for the Winamp bug where the...
  15. extern AlbumArtLayer.onAlbumArtLoaded(boolean success);
  16. ...event stops working.
  17. Please note that this workaround only kicks in if the above event stops responding.
  18. If you want to test the workaround, just add // after the FORCE_BUG_MODE below.
  19. Once the above event stop responding the first notifier trigger will be delayed (3 sec),
  20. but after that there will be no delays anymore.
  21. To remove this fix in the future just search //BUGFIX for steps ;)
  22. -----------------------------------------------------
  23. ---------------------------------------------------*/
  24. #define FORCE_BUG_MODE
  25. #include <lib/std.mi>
  26. #include attribs/init_notifier.m
  27. #define DEBUG
  28. #define DebugString //
  29. Function reset();
  30. Function createNotifier(boolean cancel);
  31. Function showNotifier(Int w);
  32. Function onNext();
  33. function cancelAnimation();
  34. Function Int fillNextTrackInfo(String corneroverride);
  35. Function Int fillCustomInfo(String customstring);
  36. Function prepareAlbumArtNotifier();
  37. Function checkPref(int bypassfs);
  38. Function getArtist();
  39. Function onAlbumArt(Boolean success);
  40. Global Container notifier_container;
  41. Global Layout notifier_layout;
  42. Global Timer notifier_timer;
  43. Global String last_autotitle, last_autopis, cur_status;
  44. Global Boolean b_tohide = 0;
  45. Global boolean handleAACalback = false;
  46. Global AlbumArtLayer cover;
  47. Global Boolean triggerBug; //BUGFIX remove this
  48. Global Timer fallbackTempFix; //BUGFIX remove this
  49. #define WEBCOVER_SHOUTCAST "winamp.cover.shoutcast"
  50. // ------------------------------------------------------------------------------
  51. // init
  52. // ------------------------------------------------------------------------------
  53. System.onScriptLoaded() {
  54. initAttribs_notifier();
  55. notifier_timer = new Timer;
  56. fallbackTempFix = new Timer; //BUGFIX remove this
  57. fallbackTempFix.setDelay(3000); //BUGFIX remove this / Time that onAlbumArtLoaded have to execute before bug mode is ON
  58. }
  59. // ------------------------------------------------------------------------------
  60. // shutdown
  61. // ------------------------------------------------------------------------------
  62. System.onScriptUnloading() {
  63. delete notifier_timer;
  64. delete fallbackTempFix; //BUGFIX remove this
  65. }
  66. // ------------------------------------------------------------------------------
  67. // called by the system when the global hotkey for notification is pressed
  68. // ------------------------------------------------------------------------------
  69. System.onShowNotification() {
  70. //if (checkPref(1)) return; --mp: if we push the hotkey, we want to show the notifier, no matter what the pref settings are.
  71. createNotifier(false);
  72. if (getStatus() == STATUS_PLAYING) cur_status = "Playing";
  73. if (getStatus() == STATUS_PAUSED) cur_status = "Playback Paused";
  74. if (getStatus() == STATUS_STOPPED) cur_status = "Playback Stopped";
  75. prepareAlbumArtNotifier();
  76. complete; // prevents other scripts from getting the message
  77. return 1; // tells anybody else that might watch the returned value that, yes, we implemented that
  78. }
  79. // ------------------------------------------------------------------------------
  80. // called by the system when the title for the playing item changes, this could be the result of the player
  81. // going to the next track, or of an update in the track title
  82. // ------------------------------------------------------------------------------
  83. // mpdeimos> seems like we get an onTitleChange callback sometimes on pause/resume, d'oh
  84. Global String lastUrl = 0;
  85. System.onTitleChange(String newtitle) {
  86. if (getPlayItemMetaDataString("streamtype") == "0" && lastUrl == getPlayItemString())
  87. {
  88. return;
  89. }
  90. lastUrl = getPlayItemString();
  91. if (StrLeft(newtitle, 1) == "[") {
  92. if (StrLeft(newtitle, 7) == "[Buffer" ||
  93. StrLeft(newtitle, 4) == "[ICY") return;
  94. }
  95. //String newpis = System.getPlayItemString();
  96. //if (last_autotitle == newtitle && last_autopis == newpis) return;
  97. //last_autotitle = newtitle;
  98. //last_autopis = newpis;
  99. DebugString("onTitleChange: "+getPlayItemString(), 9);
  100. onNext();
  101. fallbackTempFix.stop(); //BUGFIX remove later
  102. fallbackTempFix.start(); //BUGFIX remove later
  103. }
  104. // ------------------------------------------------------------------------------
  105. // called by the system when the user clicks the next button
  106. // ------------------------------------------------------------------------------
  107. onNext() {
  108. if (checkPref(0)) return;
  109. createNotifier(false);
  110. cur_status = "";
  111. prepareAlbumArtNotifier();
  112. }
  113. // ------------------------------------------------------------------------------
  114. // called by the system when the user clicks the play button
  115. // ------------------------------------------------------------------------------
  116. System.onPlay() {
  117. if (checkPref(0)) return;
  118. createNotifier(false);
  119. cur_status = "Playing";
  120. prepareAlbumArtNotifier();
  121. }
  122. // ------------------------------------------------------------------------------
  123. // called by the system when the user clicks the pause button
  124. // ------------------------------------------------------------------------------
  125. System.onPause() {
  126. fallbackTempFix.stop();
  127. if (checkPref(0)) return;
  128. DebugString("onPause",9);
  129. createNotifier(true);
  130. showNotifier(fillCustomInfo("Playback Paused"));
  131. }
  132. // ------------------------------------------------------------------------------
  133. // called by the system when the user clicks the pause button again
  134. // ------------------------------------------------------------------------------
  135. System.onResume() {
  136. if (checkPref(0)) return;
  137. DebugString("onResume",9);
  138. createNotifier(false);
  139. cur_status = "Resuming Playback";
  140. prepareAlbumArtNotifier();
  141. }
  142. // ------------------------------------------------------------------------------
  143. // called by the system when the user clicks the play button
  144. // ------------------------------------------------------------------------------
  145. System.onStop() {
  146. fallbackTempFix.stop();
  147. if (checkPref(0)) return;
  148. createNotifier(true);
  149. showNotifier(fillCustomInfo("End of Playback"));
  150. }
  151. // ------------------------------------------------------------------------------
  152. // checks if we should display anything
  153. // ------------------------------------------------------------------------------
  154. Int checkPref(int bypassfs) {
  155. if (!bypassfs && notifier_hideinfullscreen_attrib.getData() == "1" && isVideoFullscreen()) return 1;
  156. if (notifier_never_attrib.getData() == "1") return 1;
  157. if (notifier_minimized_attrib.getData() == "1" && !isMinimized()) return 1;
  158. if (notifier_windowshade_attrib.getData() == "1") {
  159. if (isMinimized()) return 0;
  160. Container c = getContainer("main");
  161. if (!c) return 1;
  162. Layout l = c.getCurLayout();
  163. if (!l) return 1;
  164. if (l.getId() != "shade") return 1;
  165. }
  166. return 0;
  167. }
  168. // ------------------------------------------------------------------------------
  169. // fade in/out completed
  170. // ------------------------------------------------------------------------------
  171. // TODO: on dual monitors the notif stays on 2nd monitor :(
  172. notifier_layout.onTargetReached() {
  173. if (b_tohide) {
  174. notifier_layout.setAlpha(0);
  175. reset();
  176. return;
  177. }
  178. int a = notifier_layout.getAlpha();
  179. if (a == 255 && !b_tohide) {
  180. notifier_timer.setDelay(StringToInteger(notifier_holdtime_attrib.getData()));
  181. notifier_timer.start();
  182. }
  183. else if (a == 0) {
  184. reset();
  185. }
  186. }
  187. // ------------------------------------------------------------------------------
  188. // hold time elapsed
  189. // ------------------------------------------------------------------------------
  190. notifier_timer.onTimer() {
  191. stop();
  192. if (notifier_fdout_alpha.getData() == "1") {
  193. if (notifier_layout.isTransparencySafe()) {
  194. notifier_layout.setTargetA(0);
  195. notifier_layout.setTargetSpeed(StringToInteger(notifier_fadeouttime_attrib.getData()) / 1000);
  196. notifier_layout.gotoTarget();
  197. return;
  198. }
  199. else {
  200. reset();
  201. return;
  202. }
  203. }
  204. else if (notifier_fdout_vslide.getData() == "1") {
  205. b_tohide = 1;
  206. int sy;
  207. int geth;
  208. Layout m = getContainer("main").getCurLayout();
  209. if (notifier_loc_vport_attrib.getData() == "1")
  210. {
  211. geth = getViewportHeightFromGuiObject(m);
  212. }
  213. else
  214. {
  215. geth = getMonitorHeightFromGuiObject(m);
  216. }
  217. if (notifier_layout.getGuiY() == 2) sy = -80;
  218. else sy = geth + 80;
  219. notifier_layout.setTargetY(sy);
  220. notifier_layout.setTargetSpeed(StringToInteger(notifier_fadeintime_attrib.getData()) / 1000);
  221. notifier_layout.gotoTarget();
  222. return;
  223. }
  224. else {
  225. if (b_tohide) return;
  226. b_tohide = 1;
  227. int sx;
  228. int getw;
  229. Layout m = getContainer("main").getCurLayout();
  230. if (notifier_loc_vport_attrib.getData() == "1") {
  231. getw = getViewportWidthFromGuiObject(m);
  232. }
  233. else {
  234. getw = getMonitorWidthFromGuiObject(m);
  235. }
  236. if (notifier_layout.getGuiX() == 2) sx = -notifier_layout.getWidth();
  237. else sx = getw + notifier_layout.getWidth();
  238. notifier_layout.setTargetX(sx);
  239. notifier_layout.setTargetSpeed(StringToInteger(notifier_fadeintime_attrib.getData()) / 1000);
  240. notifier_layout.gotoTarget();
  241. return;
  242. }
  243. }
  244. // ------------------------------------------------------------------------------
  245. // when notifier is clicked, bring back the app from minimized state if its minimized and focus it
  246. // ------------------------------------------------------------------------------
  247. notifier_layout.onLeftButtonDown(int x, int y) {
  248. cancelAnimation();
  249. restoreApplication();
  250. activateApplication();
  251. /*if (notifier_opennowplaying_attrib.getData() == "1")
  252. {
  253. String artist = getArtist();
  254. if (artist == "") return;
  255. System.navigateUrlBrowser("http://client.winamp.com/nowplaying/artist/?icid=notifierbento&artistName=" + artist);
  256. }*/
  257. reset();
  258. }
  259. notifier_layout.onRightButtonUp(int x, int y) {
  260. cancelAnimation();
  261. reset();
  262. complete;
  263. return;
  264. }
  265. //TODO merge w/ code below
  266. String getArtist ()
  267. {
  268. String artist = getPlayItemMetaDataString("artist");
  269. if (artist == "") artist = getPlayItemMetaDataString("uvox/artist");
  270. if (artist == "") artist = getPlayItemMetaDataString("cbs/artist");
  271. if (artist == "") artist = getPlayItemMetaDataString("streamtitle");
  272. if (artist == "") artist = getPlayItemDisplayTitle();
  273. return artist;
  274. }
  275. // ------------------------------------------------------------------------------
  276. // close the notifier window, destroys the container automatically because it's dynamic
  277. // ------------------------------------------------------------------------------
  278. reset() {
  279. notifier_container.close();
  280. notifier_container = NULL;
  281. notifier_layout = NULL;
  282. handleAACalback = FALSE;
  283. }
  284. // ------------------------------------------------------------------------------
  285. createNotifier(boolean cancel) {
  286. if (notifier_container == NULL) {
  287. notifier_container = newDynamicContainer("notifier");
  288. if (!notifier_container) return; // reinstall duh!
  289. if (isDesktopAlphaAvailable())
  290. notifier_layout = notifier_container.getLayout("desktopalpha");
  291. else
  292. notifier_layout = notifier_container.getLayout("normal");
  293. if (!notifier_layout) return; // reinstall twice, man
  294. } else if (cancel) {
  295. cancelAnimation();
  296. }
  297. }
  298. cancelAnimation()
  299. {
  300. notifier_layout.cancelTarget();
  301. notifier_timer.stop();
  302. }
  303. // ------------------------------------------------------------------------------
  304. showNotifier(int w) {
  305. DebugString(IntegerToString(w), 0);
  306. b_tohide = 0;
  307. int x; int y;
  308. int sy; int sx;
  309. w = w + 30;
  310. int getx, gety, geth, getw;
  311. Layout m = getContainer("main").getCurLayout();
  312. if (notifier_loc_vport_attrib.getData() == "1")
  313. {
  314. getx = getViewportLeftFromGuiObject(m);
  315. gety = getViewportTopFromGuiObject(m);
  316. geth = getViewportHeightFromGuiObject(m);
  317. getw = getViewportWidthFromGuiObject(m);
  318. }
  319. else
  320. {
  321. getx = getMonitorLeftFromGuiObject(m);
  322. gety = getMonitorTopFromGuiObject(m);
  323. geth = getMonitorHeightFromGuiObject(m);
  324. getw = getMonitorWidthFromGuiObject(m);
  325. }
  326. if (notifier_loc_br_attrib.getData() == "1") {
  327. x = getw + getx - w - 2;
  328. y = geth + gety - 80 - 2;
  329. }
  330. else if (notifier_loc_bl_attrib.getData() == "1") {
  331. x = getx + 2;
  332. y = geth + gety - 80 - 2;
  333. }
  334. else if (notifier_loc_bc_attrib.getData() == "1") {
  335. x = getx + ((getw - w) / 2);
  336. y = geth + gety - 80 - 2;
  337. }
  338. else if (notifier_loc_tr_attrib.getData() == "1") {
  339. x = getw + getx - w - 2;
  340. y = 2;
  341. }
  342. else if (notifier_loc_tc_attrib.getData() == "1") {
  343. x = getx + ((getw - w) / 2);
  344. y = 2;
  345. }
  346. else {
  347. x = getx + 2;
  348. y = 2;
  349. }
  350. if (notifier_fdin_alpha.getData() == "1") {
  351. if (!notifier_layout.isVisible()) notifier_layout.resize(x, y, w, 80);
  352. else
  353. {
  354. notifier_layout.resize(notifier_layout.getguiX(), y, notifier_layout.getGuiW(), 80);
  355. }
  356. if (notifier_layout.isTransparencySafe()) {
  357. notifier_layout.show();
  358. notifier_layout.settargetA(255);
  359. notifier_layout.setTargetX(x);
  360. notifier_layout.setTargetY(y);
  361. notifier_layout.setTargetW(w);
  362. notifier_layout.setTargetH(80);
  363. notifier_layout.setTargetSpeed(StringToInteger(notifier_fadeintime_attrib.getData()) / 1000);
  364. notifier_layout.gotoTarget();
  365. } else {
  366. notifier_layout.setAlpha(255);
  367. notifier_layout.show();
  368. notifier_layout.settargetA(255);
  369. notifier_layout.setTargetX(x);
  370. notifier_layout.setTargetY(y);
  371. notifier_layout.setTargetW(w);
  372. notifier_layout.setTargetH(80);
  373. notifier_timer.setDelay(StringToInteger(notifier_holdtime_attrib.getData()));
  374. notifier_timer.start();
  375. }
  376. }
  377. else if (notifier_fdin_vslide.getData() == "1") {
  378. if (y == 2) sy = -80;
  379. else sy = geth + 80;
  380. if (!notifier_layout.isVisible()) notifier_layout.resize(x, sy, w, 80);
  381. else
  382. {
  383. notifier_layout.resize(notifier_layout.getguiX(), y, notifier_layout.getGuiW(), 80);
  384. }
  385. notifier_layout.show();
  386. notifier_layout.setAlpha(255);
  387. notifier_layout.setTargetX(x);
  388. notifier_layout.setTargetY(y);
  389. notifier_layout.setTargetW(w);
  390. notifier_layout.setTargetH(80);
  391. notifier_layout.setTargetSpeed(StringToInteger(notifier_fadeintime_attrib.getData()) / 1000);
  392. notifier_layout.gotoTarget();
  393. }
  394. else {
  395. if (x < (getw + getx)/2) sx = -w;
  396. else sx = getw + w;
  397. if (!notifier_layout.isVisible()) {
  398. notifier_layout.resize(sx, y, w, 80);
  399. }
  400. else {
  401. notifier_layout.resize(notifier_layout.getguiX(), y, notifier_layout.getGuiW(), 80);
  402. }
  403. notifier_layout.show();
  404. notifier_layout.setAlpha(255);
  405. notifier_layout.setTargetX(x);
  406. notifier_layout.setTargetY(y);
  407. notifier_layout.setTargetW(w);
  408. notifier_layout.setTargetH(80);
  409. notifier_layout.setTargetSpeed(StringToInteger(notifier_fadeintime_attrib.getData()) / 1000);
  410. notifier_layout.gotoTarget();
  411. }
  412. }
  413. // ------------------------------------------------------------------------------
  414. prepareAlbumArtNotifier()
  415. {
  416. if (!notifier_layout) return;
  417. Group g_albumart = notifier_layout.findObject("notifier.albumart");
  418. DebugString("prepareAlbumArtNotifier: handleAACalback="+integerToString(handleAACalback), 9);
  419. if (g_albumart)
  420. {
  421. cover = g_albumart.findObject("notifier.cover");
  422. DebugString("prepareAlbumArtNotifier: cover.isLoading="+integerToString(cover.isLoading()), 9);
  423. DebugString("prepareAlbumArtNotifier: cover.isInvalid="+integerToString(cover.isInvalid()), 9);
  424. handleAACalback = true;
  425. cover.refresh();
  426. }
  427. }
  428. cover.onAlbumArtLoaded(boolean success)
  429. {
  430. /*
  431. Created a seperate function for the code that was here because for some reason I couldn't force this
  432. event (from the fallbackTempFix.onTimer) with cover.onAlbumArtLoaded(success) after the Winamp bug appears.
  433. Weird, yes.
  434. */
  435. FORCE_BUG_MODE onAlbumArt(success);
  436. }
  437. // ------------------------------------------------------------------------------
  438. Int fillNextTrackInfo(String corneroverride) {
  439. Int maxv = 0;
  440. Int stream = 0;
  441. if (!notifier_layout) return 0;
  442. Group g_text = notifier_layout.findObject("notifier.text");
  443. Group g_albumart = notifier_layout.findObject("notifier.albumart");
  444. Text plentry = g_text.findObject("plentry");
  445. Text nexttrack = g_text.findObject("nexttrack");
  446. Text _title = g_text.findObject("title");
  447. Text album = g_text.findObject("album");
  448. Text artist = g_text.findObject("artist");
  449. Text endofplayback = notifier_layout.findObject("endofplayback");
  450. Text s_plentry = g_text.findObject("plentry.shadow");
  451. Text s_nexttrack = g_text.findObject("nexttrack.shadow");
  452. Text s_title = g_text.findObject("title.shadow");
  453. Text s_album = g_text.findObject("album.shadow");
  454. Text s_artist = g_text.findObject("artist.shadow");
  455. Text s_endofplayback = notifier_layout.findObject("endofplayback.shadow");
  456. DebugString("got callback for " + getPlayItemString(), 0);
  457. // Get Stream Name - if no stream returns ""
  458. string s = getPlayItemMetaDataString("streamname");
  459. string stype = getPlayItemMetaDataString("streamtype"); //"streamtype" will return "2" for SHOUTcast and "5" for SHOUTcast 2
  460. if (stype == "2" || stype == "5") stream = 1;
  461. if (endofplayback) endofplayback.hide();
  462. if (s_endofplayback) s_endofplayback.hide();
  463. if (plentry)
  464. {
  465. plentry.setText(integerToString(getPlaylistIndex()+1)+translate(" of ")+integerToString(getPlaylistLength()));
  466. plentry.show();
  467. s_plentry.setText(integerToString(getPlaylistIndex()+1)+translate(" of ")+integerToString(getPlaylistLength()));
  468. s_plentry.show();
  469. }
  470. if (nexttrack) {
  471. if (corneroverride == "") {
  472. if (!stream) {
  473. if (!isVideo())
  474. {
  475. nexttrack.setText("New track");
  476. s_nexttrack.setText("New track");
  477. }
  478. else
  479. {
  480. nexttrack.setText("New video");
  481. s_nexttrack.setText("New video");
  482. }
  483. }
  484. else
  485. {
  486. nexttrack.setText("On air");
  487. s_nexttrack.setText("On air");
  488. }
  489. }
  490. else
  491. {
  492. nexttrack.setText(corneroverride);
  493. s_nexttrack.setText(corneroverride);
  494. }
  495. nexttrack.show();
  496. s_nexttrack.show();
  497. }
  498. string set_artist = "";
  499. string set = "";
  500. if (_title) {
  501. _title.setXmlParam("ticker", "0");
  502. _title.setXmlParam("display", "");
  503. s_title.setXmlParam("ticker", "0");
  504. s_title.setXmlParam("display", "");
  505. String str;
  506. if (!stream)
  507. {
  508. str = getPlayitemMetaDataString("title");
  509. if (str == "") str = getPlayitemDisplayTitle();
  510. String l = getPlayItemMetaDataString("length");
  511. if (l != "") {
  512. str += " (" + integerToTime(stringtointeger(l)) + ")";
  513. }
  514. _title.setText(str);
  515. s_title.setText(str);
  516. }
  517. else
  518. {
  519. if (str = getPlayItemMetaDataString("streamtitle") != "")
  520. {
  521. int v = strsearch(str, " - "); // We divide the string by a " - " sublimiter - no luck for old / wrong tagged stations
  522. if (v > 0) {
  523. set_artist = strleft (str, v); // Store artist
  524. string str = strright (str, strlen(str) - 3 - v);
  525. _title.setText(str);
  526. s_title.setText(str);
  527. }
  528. else
  529. {
  530. _title.setXmlParam("ticker", "1"); // These titles can be _very_ long
  531. s_title.setXmlParam("ticker", "1");
  532. _title.setText(str);
  533. s_title.setText(str);
  534. }
  535. } else {
  536. _title.setXmlParam("ticker", "1");
  537. _title.setXmlParam("display", "songtitle");
  538. _title.setText("");
  539. s_title.setXmlParam("ticker", "1");
  540. s_title.setXmlParam("display", "songtitle");
  541. s_title.setText("");
  542. }
  543. }
  544. _title.show();
  545. s_title.show();
  546. }
  547. if (artist) {
  548. if (!stream) {
  549. if (isVideo())
  550. {
  551. artist.setText("");
  552. s_artist.setText("");
  553. }
  554. else
  555. {
  556. artist.setText(getPlayitemMetaDataString("artist"));
  557. s_artist.setText(getPlayitemMetaDataString("artist"));
  558. }
  559. }
  560. else
  561. {
  562. // Perhaps we've stored the artist before?
  563. if (set_artist != "")
  564. {
  565. artist.setText(set_artist);
  566. s_artist.setText(set_artist);
  567. }
  568. // Then display the station name
  569. else if (s != "")
  570. {
  571. artist.setText(s);
  572. s_artist.setText(s);
  573. }
  574. // So, we've had no luck - just display a static text :(
  575. else
  576. {
  577. if (isVideo())
  578. {
  579. artist.setText("Internet TV");
  580. s_artist.setText("Internet TV");
  581. }
  582. else
  583. {
  584. artist.setText("Internet Radio");
  585. s_artist.setText("Internet Radio");
  586. }
  587. }
  588. }
  589. artist.show();
  590. s_artist.show();
  591. }
  592. if (album) {
  593. String str;
  594. if (!stream && !isVideo()) {
  595. s_album.setXmlParam("display", "");
  596. album.setXmlParam("display", "");
  597. str = getPlayitemMetaDataString("album");
  598. String l = getPlayitemMetaDataString("track");
  599. if (l != "" && l != "-1") str += " (" + translate("Track ") + l + ")";
  600. album.setText(str);
  601. s_album.setText(str);
  602. }
  603. else
  604. {
  605. album.setXmlParam("display", "");
  606. s_album.setXmlParam("display", "");
  607. // we have divided the songname - let's display the station name
  608. if (set_artist != "" && s != "")
  609. {
  610. album.setText(s);
  611. s_album.setText(s);
  612. }
  613. // no luck either...
  614. else
  615. {
  616. album.setText("");
  617. album.setXmlParam("display", "songinfo_localise");
  618. s_album.setText("");
  619. s_album.setXmlParam("display", "songinfo_localise");
  620. }
  621. }
  622. album.show();
  623. s_album.show();
  624. }
  625. // Album Art Stuff
  626. Layer webcover;
  627. if (g_albumart)
  628. {
  629. cover = g_albumart.findObject("notifier.cover");
  630. webcover = g_albumart.findObject("notifier.webcover");
  631. }
  632. Boolean showAlbumArt = FALSE;
  633. if (cover != NULL && webcover != NULL && notifier_artworkinnotification_attrib.getData() == "1")
  634. {
  635. if (stream)
  636. {
  637. if(stype == "2" || stype == "5" && cover.isInvalid())
  638. {
  639. webcover.setXMLParam("image", WEBCOVER_SHOUTCAST);
  640. cover.hide();
  641. webcover.show();
  642. showAlbumArt = TRUE;
  643. }
  644. else if(stype == "5" && !cover.isInvalid())
  645. {
  646. webcover.hide();
  647. cover.show();
  648. showAlbumArt = TRUE;
  649. }
  650. }
  651. else
  652. {
  653. if (cover.isInvalid()) // Check if the album art obj shows a pic
  654. {
  655. showAlbumArt = FALSE;
  656. }
  657. else
  658. {
  659. webcover.hide();
  660. cover.show();
  661. showAlbumArt = TRUE;
  662. }
  663. }
  664. }
  665. if (showAlbumArt)
  666. {
  667. if (g_albumart) g_albumart.show();
  668. if (g_text) g_text.setXmlParam("x", "75");
  669. if (g_text) g_text.setXmlParam("w", "-95");
  670. }
  671. else
  672. {
  673. if (g_albumart) g_albumart.hide();
  674. if (g_text) g_text.setXmlParam("x", "15");
  675. if (g_text) g_text.setXmlParam("w", "-35");
  676. }
  677. if (g_text) g_text.show();
  678. maxv = artist.getAutoWidth();
  679. if (maxv < album.getAutoWidth()) maxv = album.getAutoWidth();
  680. if (maxv < _title.getAutoWidth()) maxv = _title.getAutoWidth();
  681. if (maxv < (plentry.getAutoWidth() + nexttrack.getAutoWidth())) maxv = (plentry.getAutoWidth() + nexttrack.getAutoWidth());
  682. if (maxv < 128) maxv = 128;
  683. int getw;
  684. Layout m = getContainer("main").getCurLayout();
  685. if (notifier_loc_vport_attrib.getData() == "1")
  686. {
  687. //getw = getViewportWidth();
  688. getw = getViewportWidthFromGuiObject(m);
  689. }
  690. else
  691. {
  692. getw = getMonitorWidthFromGuiObject(m);
  693. }
  694. if (maxv > getw/4) maxv = getw/4;
  695. return maxv + ( showAlbumArt * 60 ) + 1; // Adds 60 extra pixels if album art is visible
  696. }
  697. // ------------------------------------------------------------------------------
  698. Int fillCustomInfo(String customtext)
  699. {
  700. Group g_text = notifier_layout.findObject("notifier.text");
  701. Group g_albumart = notifier_layout.findObject("notifier.albumart");
  702. Text endofplayback = notifier_layout.findObject("endofplayback");
  703. Text s_endofplayback = notifier_layout.findObject("endofplayback.shadow");
  704. if (g_text) { g_text.hide(); }
  705. if (g_albumart) g_albumart.hide();
  706. if (endofplayback != NULL && s_endofplayback != NULL) {
  707. endofplayback.setText(translate(customtext)+" ");
  708. s_endofplayback.setText(translate(customtext)+" ");
  709. int aw = endofplayback.getAutoWidth();
  710. endofplayback.show();
  711. s_endofplayback.show();
  712. if (aw > 128)
  713. return aw;
  714. }
  715. return 128;
  716. }
  717. //BUGFIX remove this timer later
  718. fallbackTempFix.onTimer() //As soon as this timer run, bug mode is ON ;)
  719. {
  720. if (checkPref(0)) return;
  721. if (!notifier_layout) onNext();
  722. if(!triggerBug)
  723. {
  724. triggerBug = true;
  725. onAlbumArt(cover.isInvalid()); //First time we see the bug
  726. fallbackTempFix.setDelay(30);
  727. DebugString("Hello Bug", 9);
  728. }
  729. else if(triggerBug && !cover.isLoading()) onAlbumArt(cover.isInvalid());
  730. }
  731. onAlbumArt(Boolean success){
  732. fallbackTempFix.stop(); //BUGFIX remove later
  733. DebugString("onAlbumArtLoaded: success="+integerToString(success), 9);
  734. DebugString("onAlbumArtLoaded: handleAACalback="+integerToString(handleAACalback), 9);
  735. DebugString("onAlbumArtLoaded: cover.isLoading="+integerToString(cover.isLoading()), 9);
  736. DebugString("onAlbumArtLoaded: cover.isInvalid="+integerToString(cover.isInvalid()), 9);
  737. if (!handleAACalback || !notifier_layout /*|| isLoading()*/)
  738. {
  739. return;
  740. }
  741. handleAACalback = cover.isLoading();
  742. cancelAnimation();
  743. showNotifier(fillNextTrackInfo(cur_status));
  744. }