index.vue 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938
  1. <template>
  2. <div>
  3. <page-metadata
  4. v-if="exists && !loading"
  5. :title="`${station.displayName}`"
  6. />
  7. <page-metadata v-else-if="!exists && !loading" :title="`Not found`" />
  8. <div id="page-loader-container" v-if="loading">
  9. <content-loader
  10. width="1920"
  11. height="1080"
  12. :primary-color="nightmode ? '#222' : '#fff'"
  13. :secondary-color="nightmode ? '#444' : '#ddd'"
  14. preserve-aspect-ratio="none"
  15. id="page-loader-content"
  16. >
  17. <rect x="55" y="105" rx="5" ry="5" width="670" height="149" />
  18. <rect x="55" y="283" rx="5" ry="5" width="670" height="640" />
  19. <rect x="745" y="108" rx="5" ry="5" width="1120" height="672" />
  20. <rect x="745" y="810" rx="5" ry="5" width="1120" height="110" />
  21. </content-loader>
  22. <content-loader
  23. width="1920"
  24. height="1080"
  25. :primary-color="nightmode ? '#222' : '#fff'"
  26. :secondary-color="nightmode ? '#444' : '#ddd'"
  27. preserve-aspect-ratio="none"
  28. id="page-loader-layout"
  29. >
  30. <rect x="0" y="0" rx="0" ry="0" width="1920" height="64" />
  31. <rect x="0" y="980" rx="0" ry="0" width="1920" height="100" />
  32. </content-loader>
  33. </div>
  34. <!-- More simplistic loading animation for mobile users -->
  35. <div v-show="loading" id="mobile-progress-animation" />
  36. <ul
  37. v-if="
  38. currentSong &&
  39. (currentSong.youtubeId === 'l9PxOanFjxQ' ||
  40. currentSong.youtubeId === 'xKVcVSYmesU' ||
  41. currentSong.youtubeId === '60ItHLz5WEA' ||
  42. currentSong.youtubeId === 'e6vkFbtSGm0')
  43. "
  44. class="bg-bubbles"
  45. >
  46. <li></li>
  47. <li></li>
  48. <li></li>
  49. <li></li>
  50. <li></li>
  51. <li></li>
  52. <li></li>
  53. <li></li>
  54. <li></li>
  55. <li></li>
  56. </ul>
  57. <div v-show="!loading && exists">
  58. <main-header />
  59. <div id="station-outer-container">
  60. <div
  61. id="station-inner-container"
  62. :class="{ 'nothing-here': noSong }"
  63. >
  64. <div id="station-left-column" class="column">
  65. <!-- div with quadrant class -->
  66. <div class="quadrant">
  67. <station-info-box
  68. :station="station"
  69. :station-paused="stationPaused"
  70. :show-manage-station="true"
  71. />
  72. </div>
  73. <div id="sidebar-container" class="quadrant">
  74. <station-sidebar />
  75. </div>
  76. </div>
  77. <div id="station-right-column" class="column">
  78. <div class="player-container quadrant" v-show="!noSong">
  79. <div id="video-container">
  80. <div
  81. id="stationPlayer"
  82. style="
  83. width: 100%;
  84. height: 100%;
  85. min-height: 200px;
  86. "
  87. />
  88. <div
  89. class="player-cannot-autoplay"
  90. v-if="!canAutoplay"
  91. @click="increaseVolume()"
  92. >
  93. <p>
  94. Please click anywhere on the screen for
  95. the video to start
  96. </p>
  97. </div>
  98. </div>
  99. <div id="seeker-bar-container">
  100. <div
  101. id="seeker-bar"
  102. :class="{
  103. 'christmas-seeker': christmas,
  104. nyan:
  105. currentSong &&
  106. currentSong.youtubeId ===
  107. 'QH2-TGUlwu4'
  108. }"
  109. />
  110. <div
  111. class="seeker-bar-cover"
  112. :style="{
  113. width: `calc(100% - ${seekerbarPercentage}%)`
  114. }"
  115. ></div>
  116. <img
  117. v-if="
  118. currentSong &&
  119. currentSong.youtubeId === 'QH2-TGUlwu4'
  120. "
  121. src="https://freepngimg.com/thumb/nyan_cat/1-2-nyan-cat-free-download-png.png"
  122. :style="{
  123. position: 'absolute',
  124. top: `-10px`,
  125. left: `${seekerbarPercentage}%`,
  126. width: '50px'
  127. }"
  128. />
  129. <img
  130. v-if="
  131. currentSong &&
  132. (currentSong.youtubeId ===
  133. 'DtVBCG6ThDk' ||
  134. currentSong.youtubeId ===
  135. 'sI66hcu9fIs' ||
  136. currentSong.youtubeId ===
  137. 'iYYRH4apXDo' ||
  138. currentSong.youtubeId ===
  139. 'tRcPA7Fzebw')
  140. "
  141. src="/assets/rocket.svg"
  142. :style="{
  143. position: 'absolute',
  144. top: `-21px`,
  145. left: `calc(${seekerbarPercentage}% - 35px)`,
  146. width: '50px',
  147. transform: 'rotate(45deg)'
  148. }"
  149. />
  150. <img
  151. v-if="
  152. currentSong &&
  153. currentSong.youtubeId === 'jofNR_WkoCE'
  154. "
  155. src="/assets/fox.svg"
  156. :style="{
  157. position: 'absolute',
  158. top: `-21px`,
  159. left: `calc(${seekerbarPercentage}% - 35px)`,
  160. width: '50px',
  161. transform: 'scaleX(-1)',
  162. opacity: 1
  163. }"
  164. />
  165. <img
  166. v-if="
  167. currentSong &&
  168. (currentSong.youtubeId ===
  169. 'l9PxOanFjxQ' ||
  170. currentSong.youtubeId ===
  171. 'xKVcVSYmesU' ||
  172. currentSong.youtubeId ===
  173. '60ItHLz5WEA' ||
  174. currentSong.youtubeId ===
  175. 'e6vkFbtSGm0')
  176. "
  177. src="/assets/old_logo.png"
  178. :style="{
  179. position: 'absolute',
  180. top: `-9px`,
  181. left: `calc(${seekerbarPercentage}% - 22px)`,
  182. 'background-color': 'rgb(96, 199, 169)',
  183. width: '25px',
  184. height: '25px',
  185. 'border-radius': '25px'
  186. }"
  187. />
  188. <img
  189. v-if="
  190. christmas &&
  191. currentSong &&
  192. ![
  193. 'QH2-TGUlwu4',
  194. 'DtVBCG6ThDk',
  195. 'sI66hcu9fIs',
  196. 'iYYRH4apXDo',
  197. 'tRcPA7Fzebw',
  198. 'jofNR_WkoCE',
  199. 'l9PxOanFjxQ',
  200. 'xKVcVSYmesU',
  201. '60ItHLz5WEA',
  202. 'e6vkFbtSGm0'
  203. ].includes(currentSong.youtubeId)
  204. "
  205. src="/assets/santa.png"
  206. :style="{
  207. position: 'absolute',
  208. top: `-30px`,
  209. left: `calc(${seekerbarPercentage}% - 25px)`,
  210. height: '50px',
  211. transform: 'scaleX(-1)'
  212. }"
  213. />
  214. </div>
  215. <div id="control-bar-container">
  216. <div id="left-buttons">
  217. <!-- Debug Box -->
  218. <button
  219. v-if="frontendDevMode === 'development'"
  220. class="button is-primary"
  221. @click="togglePlayerDebugBox()"
  222. @dblclick="resetPlayerDebugBox()"
  223. content="Debug"
  224. v-tippy
  225. >
  226. <i
  227. class="material-icons icon-with-button"
  228. >
  229. bug_report
  230. </i>
  231. </button>
  232. <!-- Local Pause/Resume Button -->
  233. <button
  234. class="button is-primary"
  235. @click="resumeLocalStation()"
  236. id="local-resume"
  237. v-if="localPaused"
  238. content="Unpause Playback"
  239. v-tippy
  240. >
  241. <i class="material-icons">play_arrow</i>
  242. </button>
  243. <button
  244. class="button is-primary"
  245. @click="pauseLocalStation()"
  246. id="local-pause"
  247. v-else
  248. content="Pause Playback"
  249. v-tippy
  250. >
  251. <i class="material-icons">pause</i>
  252. </button>
  253. <!-- Vote to Skip Button -->
  254. <button
  255. v-if="!skipVotesLoaded"
  256. class="button is-primary disabled"
  257. content="Skip votes have not been loaded yet"
  258. v-tippy
  259. >
  260. <i
  261. class="material-icons icon-with-button"
  262. >skip_next</i
  263. >
  264. </button>
  265. <button
  266. v-else-if="loggedIn"
  267. class="button is-primary"
  268. @click="voteSkipStation()"
  269. content="Vote to Skip Song"
  270. v-tippy
  271. >
  272. <i
  273. class="material-icons icon-with-button"
  274. >skip_next</i
  275. >
  276. {{ currentSong.skipVotes }}
  277. </button>
  278. <button
  279. v-else
  280. class="button is-primary disabled"
  281. content="Log in to vote to skip songs"
  282. v-tippy="{ theme: 'info' }"
  283. >
  284. <i
  285. class="material-icons icon-with-button"
  286. >skip_next</i
  287. >
  288. {{ currentSong.skipVotes }}
  289. </button>
  290. </div>
  291. <div id="duration">
  292. <p>
  293. {{ timeElapsed }} /
  294. {{
  295. utils.formatTime(
  296. currentSong.duration
  297. )
  298. }}
  299. </p>
  300. </div>
  301. <p id="volume-control" v-if="!isApple">
  302. <i
  303. class="material-icons"
  304. @click="toggleMute()"
  305. :content="`${
  306. muted ? 'Unmute' : 'Mute'
  307. }`"
  308. v-tippy
  309. >{{
  310. muted
  311. ? "volume_mute"
  312. : volumeSliderValue >= 50
  313. ? "volume_up"
  314. : "volume_down"
  315. }}</i
  316. >
  317. <input
  318. v-model="volumeSliderValue"
  319. type="range"
  320. min="0"
  321. max="100"
  322. class="volume-slider active"
  323. @change="changeVolume()"
  324. @input="changeVolume()"
  325. />
  326. </p>
  327. <div id="right-buttons" v-if="loggedIn">
  328. <!-- Ratings (Like/Dislike) Buttons -->
  329. <div
  330. id="ratings"
  331. v-if="ratingsLoaded && ownRatingsLoaded"
  332. :class="{
  333. liked: currentSong.liked,
  334. disliked: currentSong.disliked
  335. }"
  336. >
  337. <!-- Like Song Button -->
  338. <button
  339. class="button is-success like-song"
  340. id="like-song"
  341. @click="toggleLike()"
  342. content="Like Song"
  343. v-tippy
  344. >
  345. <i
  346. class="material-icons icon-with-button"
  347. :class="{
  348. liked: currentSong.liked
  349. }"
  350. >thumb_up_alt</i
  351. >{{ currentSong.likes }}
  352. </button>
  353. <!-- Dislike Song Button -->
  354. <button
  355. class="button is-danger dislike-song"
  356. id="dislike-song"
  357. @click="toggleDislike()"
  358. content="Dislike Song"
  359. v-tippy
  360. >
  361. <i
  362. class="material-icons icon-with-button"
  363. :class="{
  364. disliked:
  365. currentSong.disliked
  366. }"
  367. >thumb_down_alt</i
  368. >{{ currentSong.dislikes }}
  369. </button>
  370. </div>
  371. <div id="ratings" class="disabled" v-else>
  372. <!-- Like Song Button -->
  373. <button
  374. class="button is-success like-song disabled"
  375. id="like-song"
  376. content="Ratings have not been loaded yet"
  377. v-tippy
  378. >
  379. <i
  380. class="material-icons icon-with-button"
  381. >thumb_up_alt</i
  382. >
  383. </button>
  384. <!-- Dislike Song Button -->
  385. <button
  386. class="button is-danger dislike-song disabled"
  387. id="dislike-song"
  388. content="Ratings have not been loaded yet"
  389. v-tippy
  390. >
  391. <i
  392. class="material-icons icon-with-button"
  393. >thumb_down_alt</i
  394. >
  395. </button>
  396. </div>
  397. <!-- Add Song To Playlist Button & Dropdown -->
  398. <add-to-playlist-dropdown
  399. :song="currentSong"
  400. placement="top-end"
  401. >
  402. <template #button>
  403. <div
  404. id="add-song-to-playlist"
  405. content="Add Song to Playlist"
  406. v-tippy
  407. >
  408. <div class="control has-addons">
  409. <button
  410. class="button is-primary"
  411. >
  412. <i
  413. class="material-icons"
  414. >
  415. playlist_add
  416. </i>
  417. </button>
  418. <button
  419. class="button"
  420. id="dropdown-toggle"
  421. >
  422. <i
  423. class="material-icons"
  424. >
  425. {{
  426. showPlaylistDropdown
  427. ? "expand_more"
  428. : "expand_less"
  429. }}
  430. </i>
  431. </button>
  432. </div>
  433. </div>
  434. </template>
  435. </add-to-playlist-dropdown>
  436. </div>
  437. <div id="right-buttons" v-else>
  438. <!-- Disabled Ratings (Like/Dislike) Buttons -->
  439. <div id="ratings" v-if="ratingsLoaded">
  440. <!-- Disabled Like Song Button -->
  441. <button
  442. class="button is-success disabled"
  443. id="like-song"
  444. content="Log in to like songs"
  445. v-tippy="{ theme: 'info' }"
  446. >
  447. <i
  448. class="material-icons icon-with-button"
  449. >thumb_up_alt</i
  450. >{{ currentSong.likes }}
  451. </button>
  452. <!-- Disabled Dislike Song Button -->
  453. <button
  454. class="button is-danger disabled"
  455. id="dislike-song"
  456. content="Log in to dislike songs"
  457. v-tippy="{ theme: 'info' }"
  458. >
  459. <i
  460. class="material-icons icon-with-button"
  461. >thumb_down_alt</i
  462. >{{ currentSong.dislikes }}
  463. </button>
  464. </div>
  465. <div id="ratings" v-else>
  466. <!-- Disabled Like Song Button -->
  467. <button
  468. class="button is-success disabled"
  469. id="like-song"
  470. content="Ratings have not been loaded yet"
  471. v-tippy="{ theme: 'info' }"
  472. >
  473. <i
  474. class="material-icons icon-with-button"
  475. >thumb_up_alt</i
  476. >
  477. </button>
  478. <!-- Disabled Dislike Song Button -->
  479. <button
  480. class="button is-danger disabled"
  481. id="dislike-song"
  482. content="Ratings have not been loaded yet"
  483. v-tippy="{ theme: 'info' }"
  484. >
  485. <i
  486. class="material-icons icon-with-button"
  487. >thumb_down_alt</i
  488. >
  489. </button>
  490. </div>
  491. <!-- Disabled Add Song To Playlist Button & Dropdown -->
  492. <div id="add-song-to-playlist">
  493. <div class="control has-addons">
  494. <button
  495. class="button is-primary disabled"
  496. content="Log in to add songs to playlist"
  497. v-tippy="{ theme: 'info' }"
  498. >
  499. <i class="material-icons"
  500. >queue</i
  501. >
  502. </button>
  503. </div>
  504. </div>
  505. </div>
  506. </div>
  507. </div>
  508. <p
  509. class="player-container nothing-here-text"
  510. v-if="noSong"
  511. >
  512. No song is currently playing
  513. </p>
  514. <div v-if="!noSong" id="current-next-row">
  515. <div
  516. id="currently-playing-container"
  517. class="quadrant"
  518. :class="{ 'no-currently-playing': noSong }"
  519. >
  520. <song-item
  521. :song="currentSong"
  522. :duration="false"
  523. :requested-by="true"
  524. header="Currently Playing.."
  525. />
  526. </div>
  527. <div
  528. v-if="nextSong"
  529. id="next-up-container"
  530. class="quadrant"
  531. >
  532. <song-item
  533. :song="nextSong"
  534. :duration="false"
  535. :requested-by="true"
  536. header="Next Up.."
  537. />
  538. </div>
  539. </div>
  540. </div>
  541. </div>
  542. </div>
  543. <main-footer />
  544. </div>
  545. <floating-box id="player-debug-box" ref="playerDebugBox">
  546. <template #body>
  547. <span><b>No song</b>: {{ noSong }}</span>
  548. <span><b>Song id</b>: {{ currentSong._id }}</span>
  549. <span><b>YouTube id</b>: {{ currentSong.youtubeId }}</span>
  550. <span><b>Duration</b>: {{ currentSong.duration }}</span>
  551. <span
  552. ><b>Skip duration</b>: {{ currentSong.skipDuration }}</span
  553. >
  554. <span><b>Loading</b>: {{ loading }}</span>
  555. <span><b>Can autoplay</b>: {{ canAutoplay }}</span>
  556. <span><b>Player ready</b>: {{ playerReady }}</span>
  557. <span
  558. ><b>Attempts to play video</b>:
  559. {{ attemptsToPlayVideo }}</span
  560. >
  561. <span
  562. ><b>Last time requested if can autoplay</b>:
  563. {{ lastTimeRequestedIfCanAutoplay }}</span
  564. >
  565. <span><b>Seeking</b>: {{ seeking }}</span>
  566. <span><b>Playback rate</b>: {{ playbackRate }}</span>
  567. <span><b>System difference</b>: {{ systemDifference }}</span>
  568. <span><b>Time before paused</b>: {{ timeBeforePause }}</span>
  569. <span><b>Time paused</b>: {{ timePaused }}</span>
  570. <span><b>Time elapsed</b>: {{ timeElapsed }}</span>
  571. <span><b>Volume slider value</b>: {{ volumeSliderValue }}</span>
  572. <span><b>Local paused</b>: {{ localPaused }}</span>
  573. <span><b>Station paused</b>: {{ stationPaused }}</span>
  574. <span
  575. ><b>Requests enabled</b>:
  576. {{ station.requests.enabled }}</span
  577. >
  578. <span
  579. ><b>Requests access</b>: {{ station.requests.access }}</span
  580. >
  581. <span><b>Requests limit</b>: {{ station.requests.limit }}</span>
  582. <span
  583. ><b>Auto requesting playlists</b>:
  584. {{
  585. autoRequest.map(playlist => playlist._id).join(", ")
  586. }}</span
  587. >
  588. <span
  589. ><b>Autofill enabled</b>:
  590. {{ station.autofill.enabled }}</span
  591. >
  592. <span><b>Autofill limit</b>: {{ station.autofill.limit }}</span>
  593. <span><b>Autofill mode</b>: {{ station.autofill.mode }}</span>
  594. <span><b>Skip votes loaded</b>: {{ skipVotesLoaded }}</span>
  595. <span
  596. ><b>Skip votes current</b>:
  597. {{
  598. currentSong.skipVotesCurrent === true ||
  599. currentSong.skipVotesCurrent === false
  600. ? currentSong.skipVotesCurrent
  601. : "N/A"
  602. }}</span
  603. >
  604. <span
  605. ><b>Skip votes</b>:
  606. {{ skipVotesLoaded ? currentSong.skipVotes : "N/A" }}</span
  607. >
  608. <span><b>Ratings loaded</b>: {{ ratingsLoaded }}</span>
  609. <span
  610. ><b>Ratings</b>:
  611. {{
  612. ratingsLoaded
  613. ? `${currentSong.likes} / ${currentSong.dislikes}`
  614. : "N/A"
  615. }}</span
  616. >
  617. <span><b>Own ratings loaded</b>: {{ ownRatingsLoaded }}</span>
  618. <span
  619. ><b>Own ratings</b>:
  620. {{
  621. ownRatingsLoaded
  622. ? `${currentSong.liked} / ${currentSong.disliked}`
  623. : "N/A"
  624. }}</span
  625. >
  626. </template>
  627. </floating-box>
  628. <floating-box
  629. id="keyboardShortcutsHelper"
  630. ref="keyboardShortcutsHelper"
  631. >
  632. <template #body>
  633. <div>
  634. <div v-if="isOwnerOrAdmin()">
  635. <span class="biggest"><b>Admin/owner</b></span>
  636. <span><b>Ctrl + Space</b> - Pause/resume station</span>
  637. <span><b>Ctrl + Numpad right</b> - Skip station</span>
  638. </div>
  639. <hr v-if="isOwnerOrAdmin()" />
  640. <div>
  641. <span class="biggest"><b>Volume</b></span>
  642. <span
  643. ><b>Ctrl + Numpad up/down</b> - Volume up/down
  644. 10%</span
  645. >
  646. <span
  647. ><b>Ctrl + Shift + Numpad up/down</b> - Volume
  648. up/down 10%</span
  649. >
  650. </div>
  651. <hr />
  652. <div>
  653. <span class="biggest"><b>Misc</b></span>
  654. <span><b>Ctrl + D</b> - Toggles debug box</span>
  655. <span><b>Ctrl + Shift + D</b> - Resets debug box</span>
  656. <span
  657. ><b>Ctrl + /</b> - Toggles keyboard shortcuts
  658. box</span
  659. >
  660. <span
  661. ><b>Ctrl + Shift + /</b> - Resets keyboard shortcuts
  662. box</span
  663. >
  664. </div>
  665. </div>
  666. </template>
  667. </floating-box>
  668. <Z404 v-if="!exists"></Z404>
  669. </div>
  670. </template>
  671. <script>
  672. import { mapState, mapActions, mapGetters } from "vuex";
  673. import Toast from "toasters";
  674. import { ContentLoader } from "vue-content-loader";
  675. import canAutoPlay from "can-autoplay";
  676. import aw from "@/aw";
  677. import ms from "@/ms";
  678. import ws from "@/ws";
  679. import keyboardShortcuts from "@/keyboardShortcuts";
  680. import FloatingBox from "@/components/FloatingBox.vue";
  681. import StationInfoBox from "@/components/StationInfoBox.vue";
  682. import AddToPlaylistDropdown from "@/components/AddToPlaylistDropdown.vue";
  683. import SongItem from "@/components/SongItem.vue";
  684. import Z404 from "../404.vue";
  685. import utils from "../../../js/utils";
  686. import StationSidebar from "./Sidebar/index.vue";
  687. export default {
  688. components: {
  689. ContentLoader,
  690. Z404,
  691. FloatingBox,
  692. StationInfoBox,
  693. StationSidebar,
  694. AddToPlaylistDropdown,
  695. SongItem
  696. },
  697. data() {
  698. return {
  699. utils,
  700. isApple:
  701. navigator.platform.match(/iPhone|iPod|iPad/) ||
  702. navigator.vendor === "Apple Computer, Inc.",
  703. title: "Station",
  704. loading: true,
  705. exists: true,
  706. playerReady: false,
  707. player: undefined,
  708. timePaused: 0,
  709. muted: false,
  710. timeElapsed: "0:00",
  711. timeBeforePause: 0,
  712. systemDifference: 0,
  713. attemptsToPlayVideo: 0,
  714. canAutoplay: true,
  715. lastTimeRequestedIfCanAutoplay: 0,
  716. seeking: false,
  717. playbackRate: 1,
  718. volumeSliderValue: 0,
  719. showPlaylistDropdown: false,
  720. theme: "var(--primary-color)",
  721. seekerbarPercentage: 0,
  722. frontendDevMode: "production",
  723. activityWatchVideoDataInterval: null,
  724. activityWatchVideoLastStatus: "",
  725. activityWatchVideoLastYouTubeId: "",
  726. activityWatchVideoLastStartDuration: "",
  727. nextCurrentSong: null,
  728. editSongModalWatcher: null,
  729. beforeEditSongModalLocalPaused: null,
  730. socketConnected: null,
  731. persistentToastCheckerInterval: null,
  732. persistentToasts: [],
  733. mediasession: false,
  734. christmas: false,
  735. sitename: "Musare"
  736. };
  737. },
  738. computed: {
  739. skipVotesLoaded() {
  740. return (
  741. !this.noSong &&
  742. Number.isInteger(this.currentSong.skipVotes) &&
  743. this.currentSong.skipVotes >= 0
  744. );
  745. },
  746. ratingsLoaded() {
  747. return (
  748. !this.noSong &&
  749. Number.isInteger(this.currentSong.likes) &&
  750. Number.isInteger(this.currentSong.dislikes) &&
  751. this.currentSong.likes >= 0 &&
  752. this.currentSong.dislikes >= 0
  753. );
  754. },
  755. ownRatingsLoaded() {
  756. return (
  757. !this.noSong &&
  758. typeof this.currentSong.liked === "boolean" &&
  759. typeof this.currentSong.disliked === "boolean"
  760. );
  761. },
  762. aModalIsOpen() {
  763. return Object.keys(this.activeModals).length > 0;
  764. },
  765. currentUserQueueSongs() {
  766. return this.songsList.filter(
  767. queueSong => queueSong.requestedBy === this.userId
  768. ).length;
  769. },
  770. ...mapState("modalVisibility", {
  771. modals: state => state.modals,
  772. activeModals: state => state.activeModals
  773. }),
  774. ...mapState("modals/editSong", {
  775. video: state => state.video
  776. }),
  777. ...mapState("station", {
  778. station: state => state.station,
  779. currentSong: state => state.currentSong,
  780. nextSong: state => state.nextSong,
  781. songsList: state => state.songsList,
  782. stationPaused: state => state.stationPaused,
  783. localPaused: state => state.localPaused,
  784. noSong: state => state.noSong,
  785. autoRequest: state => state.autoRequest,
  786. autoRequestLock: state => state.autoRequestLock,
  787. autofill: state => state.autofill,
  788. blacklist: state => state.blacklist
  789. }),
  790. ...mapState({
  791. loggedIn: state => state.user.auth.loggedIn,
  792. userId: state => state.user.auth.userId,
  793. role: state => state.user.auth.role,
  794. nightmode: state => state.user.preferences.nightmode,
  795. autoSkipDisliked: state => state.user.preferences.autoSkipDisliked
  796. }),
  797. ...mapGetters({
  798. socket: "websockets/getSocket"
  799. })
  800. },
  801. watch: {
  802. "autoRequest.length": function autoRequestWatcher() {
  803. this.autoRequestSong();
  804. }
  805. },
  806. async mounted() {
  807. this.editSongModalWatcher = this.$store.watch(
  808. state =>
  809. state.modalVisibility.activeModals.length > 0 &&
  810. state.modalVisibility.modals[
  811. state.modalVisibility.activeModals[
  812. state.modalVisibility.activeModals.length - 1
  813. ]
  814. ] === "editSong"
  815. ? state.modals.editSong[
  816. state.modalVisibility.activeModals[
  817. state.modalVisibility.activeModals.length - 1
  818. ]
  819. ].video.paused
  820. : null,
  821. paused => {
  822. if (paused && !this.beforeEditSongModalLocalPaused) {
  823. this.resumeLocalStation();
  824. } else if (!paused) {
  825. this.beforeEditSongModalLocalPaused = this.localPaused;
  826. this.pauseLocalStation();
  827. }
  828. }
  829. );
  830. window.scrollTo(0, 0);
  831. Date.currently = () => new Date().getTime() + this.systemDifference;
  832. this.stationIdentifier = this.$route.params.id;
  833. window.stationInterval = 0;
  834. this.activityWatchVideoDataInterval = setInterval(() => {
  835. this.sendActivityWatchVideoData();
  836. }, 1000);
  837. this.persistentToastCheckerInterval = setInterval(() => {
  838. this.persistentToasts.filter(
  839. persistentToast => !persistentToast.checkIfCanRemove()
  840. );
  841. }, 1000);
  842. if (this.socket.readyState === 1) this.join();
  843. ws.onConnect(() => {
  844. this.socketConnected = true;
  845. clearTimeout(window.stationNextSongTimeout);
  846. this.join();
  847. });
  848. ws.onDisconnect(true, () => {
  849. this.socketConnected = false;
  850. const { currentSong } = this.currentSong;
  851. if (this.nextSong)
  852. this.setNextCurrentSong(
  853. {
  854. currentSong: this.nextSong,
  855. startedAt: Date.now() + this.getTimeRemaining(),
  856. paused: false,
  857. timePaused: 0
  858. },
  859. true
  860. );
  861. else
  862. this.setNextCurrentSong(
  863. {
  864. currentSong: null,
  865. startedAt: 0,
  866. paused: false,
  867. timePaused: 0,
  868. pausedAt: 0
  869. },
  870. true
  871. );
  872. window.stationNextSongTimeout = setTimeout(() => {
  873. if (!this.noSong && this.currentSong._id === currentSong._id)
  874. this.skipSong("window.stationNextSongTimeout 2");
  875. }, this.getTimeRemaining());
  876. });
  877. this.frontendDevMode = await lofig.get("mode");
  878. this.mediasession = await lofig.get("siteSettings.mediasession");
  879. this.christmas = await lofig.get("siteSettings.christmas");
  880. this.sitename = await lofig.get("siteSettings.sitename");
  881. this.socket.dispatch(
  882. "stations.existsByName",
  883. this.stationIdentifier,
  884. res => {
  885. if (res.status === "error" || !res.data.exists) {
  886. // station identifier may be using stationid instead
  887. this.socket.dispatch(
  888. "stations.existsById",
  889. this.stationIdentifier,
  890. res => {
  891. if (res.status === "error" || !res.data.exists) {
  892. this.loading = false;
  893. this.exists = false;
  894. }
  895. }
  896. );
  897. }
  898. }
  899. );
  900. ms.setListeners(0, {
  901. play: () => {
  902. if (this.isOwnerOrAdmin()) this.resumeStation();
  903. else this.resumeLocalStation();
  904. },
  905. pause: () => {
  906. if (this.isOwnerOrAdmin()) this.pauseStation();
  907. else this.pauseLocalStation();
  908. },
  909. nexttrack: () => {
  910. if (this.isOwnerOrAdmin()) this.skipStation();
  911. else this.voteSkipStation();
  912. }
  913. });
  914. this.socket.on("event:station.nextSong", res => {
  915. const { currentSong, startedAt, paused, timePaused } = res.data;
  916. this.setCurrentSong({
  917. currentSong,
  918. startedAt,
  919. paused,
  920. timePaused,
  921. pausedAt: 0
  922. });
  923. });
  924. this.socket.on("event:station.pause", res => {
  925. this.pausedAt = res.data.pausedAt;
  926. this.updateStationPaused(true);
  927. this.pauseLocalPlayer();
  928. clearTimeout(window.stationNextSongTimeout);
  929. });
  930. this.socket.on("event:station.resume", res => {
  931. this.timePaused = res.data.timePaused;
  932. this.updateStationPaused(false);
  933. if (!this.localPaused) this.resumeLocalPlayer();
  934. this.autoRequestSong();
  935. });
  936. this.socket.on("event:station.deleted", () => {
  937. window.location.href = "/?msg=The station you were in was deleted.";
  938. return true;
  939. });
  940. this.socket.on("event:song.liked", res => {
  941. if (!this.noSong) {
  942. if (res.data.youtubeId === this.currentSong.youtubeId) {
  943. this.updateCurrentSongRatings(res.data);
  944. }
  945. }
  946. });
  947. this.socket.on("event:song.disliked", res => {
  948. if (!this.noSong) {
  949. if (res.data.youtubeId === this.currentSong.youtubeId) {
  950. this.updateCurrentSongRatings(res.data);
  951. }
  952. }
  953. });
  954. this.socket.on("event:song.unliked", res => {
  955. if (!this.noSong) {
  956. if (res.data.youtubeId === this.currentSong.youtubeId) {
  957. this.updateCurrentSongRatings(res.data);
  958. }
  959. }
  960. });
  961. this.socket.on("event:song.undisliked", res => {
  962. if (!this.noSong) {
  963. if (res.data.youtubeId === this.currentSong.youtubeId) {
  964. this.updateCurrentSongRatings(res.data);
  965. }
  966. }
  967. });
  968. this.socket.on("event:song.ratings.updated", res => {
  969. if (!this.noSong) {
  970. if (res.data.youtubeId === this.currentSong.youtubeId) {
  971. this.updateOwnCurrentSongRatings(res.data);
  972. }
  973. }
  974. });
  975. this.socket.on("event:station.queue.updated", res => {
  976. this.updateSongsList(res.data.queue);
  977. let nextSong = null;
  978. if (this.songsList[0])
  979. nextSong = this.songsList[0].youtubeId
  980. ? this.songsList[0]
  981. : null;
  982. this.updateNextSong(nextSong);
  983. this.autoRequestSong();
  984. });
  985. this.socket.on("event:station.queue.song.repositioned", res => {
  986. this.repositionSongInList(res.data.song);
  987. let nextSong = null;
  988. if (this.songsList[0])
  989. nextSong = this.songsList[0].youtubeId
  990. ? this.songsList[0]
  991. : null;
  992. this.updateNextSong(nextSong);
  993. });
  994. this.socket.on("event:station.voteSkipSong", () => {
  995. if (this.currentSong)
  996. this.updateCurrentSongSkipVotes({
  997. skipVotes: this.currentSong.skipVotes + 1,
  998. skipVotesCurrent: null
  999. });
  1000. });
  1001. this.socket.on("event:station.updated", async res => {
  1002. const { name, theme, privacy } = res.data.station;
  1003. if (!this.isOwnerOrAdmin() && privacy === "private") {
  1004. window.location.href =
  1005. "/?msg=The station you were in was made private.";
  1006. } else {
  1007. if (this.station.name !== name) {
  1008. await this.$router.push(
  1009. `${name}?${Object.keys(this.$route.query)
  1010. .map(
  1011. key =>
  1012. `${encodeURIComponent(
  1013. key
  1014. )}=${encodeURIComponent(
  1015. this.$route.query[key]
  1016. )}`
  1017. )
  1018. .join("&")}`
  1019. );
  1020. // eslint-disable-next-line no-restricted-globals
  1021. history.replaceState({ ...history.state, ...{} }, null);
  1022. }
  1023. if (this.station.theme !== theme)
  1024. document.getElementsByTagName(
  1025. "html"
  1026. )[0].style.cssText = `--primary-color: var(--${theme})`;
  1027. this.updateStation(res.data.station);
  1028. }
  1029. });
  1030. this.socket.on("event:station.users.updated", res =>
  1031. this.updateUsers(res.data.users)
  1032. );
  1033. this.socket.on("event:station.userCount.updated", res =>
  1034. this.updateUserCount(res.data.userCount)
  1035. );
  1036. this.socket.on("event:user.station.favorited", res => {
  1037. if (res.data.stationId === this.station._id)
  1038. this.updateIfStationIsFavorited({ isFavorited: true });
  1039. });
  1040. this.socket.on("event:user.station.unfavorited", res => {
  1041. if (res.data.stationId === this.station._id)
  1042. this.updateIfStationIsFavorited({ isFavorited: false });
  1043. });
  1044. if (JSON.parse(localStorage.getItem("muted"))) {
  1045. this.muted = true;
  1046. this.player.setVolume(0);
  1047. this.volumeSliderValue = 0;
  1048. } else {
  1049. let volume = parseFloat(localStorage.getItem("volume"));
  1050. volume =
  1051. typeof volume === "number" && !Number.isNaN(volume)
  1052. ? volume
  1053. : 20;
  1054. localStorage.setItem("volume", volume);
  1055. this.volumeSliderValue = volume;
  1056. }
  1057. },
  1058. beforeUnmount() {
  1059. document.getElementsByTagName("html")[0].style.cssText = "";
  1060. if (this.mediasession) {
  1061. ms.removeListeners(0);
  1062. ms.removeMediaSessionData(0);
  1063. }
  1064. /** Reset Songslist */
  1065. this.updateSongsList([]);
  1066. const shortcutNames = [
  1067. "station.pauseResume",
  1068. "station.skipStation",
  1069. "station.lowerVolumeLarge",
  1070. "station.lowerVolumeSmall",
  1071. "station.increaseVolumeLarge",
  1072. "station.increaseVolumeSmall",
  1073. "station.toggleDebug"
  1074. ];
  1075. shortcutNames.forEach(shortcutName => {
  1076. keyboardShortcuts.unregisterShortcut(shortcutName);
  1077. });
  1078. this.editSongModalWatcher(); // removes the watcher
  1079. clearInterval(this.activityWatchVideoDataInterval);
  1080. clearTimeout(window.stationNextSongTimeout);
  1081. clearTimeout(this.persistentToastCheckerInterval);
  1082. this.persistentToasts.forEach(persistentToast => {
  1083. persistentToast.toast.destroy();
  1084. });
  1085. this.socket.dispatch("stations.leave", this.station._id, () => {});
  1086. this.leaveStation();
  1087. },
  1088. methods: {
  1089. isOwnerOnly() {
  1090. return this.loggedIn && this.userId === this.station.owner;
  1091. },
  1092. isAdminOnly() {
  1093. return this.loggedIn && this.role === "admin";
  1094. },
  1095. isOwnerOrAdmin() {
  1096. return this.isOwnerOnly() || this.isAdminOnly();
  1097. },
  1098. updateMediaSessionData(currentSong) {
  1099. if (currentSong) {
  1100. ms.setMediaSessionData(
  1101. 0,
  1102. !this.localPaused && !this.stationPaused, // This should be improved later
  1103. this.currentSong.title,
  1104. this.currentSong.artists.join(", "),
  1105. null,
  1106. this.currentSong.thumbnail
  1107. );
  1108. } else ms.removeMediaSessionData(0);
  1109. },
  1110. autoRequestSong() {
  1111. if (
  1112. !this.autoRequestLock &&
  1113. this.songsList.length < 50 &&
  1114. this.currentUserQueueSongs <
  1115. this.station.requests.limit * 0.5 &&
  1116. this.autoRequest.length > 0
  1117. ) {
  1118. const selectedPlaylist =
  1119. this.autoRequest[
  1120. Math.floor(Math.random() * this.autoRequest.length)
  1121. ];
  1122. if (selectedPlaylist._id && selectedPlaylist.songs.length > 0) {
  1123. const selectedSong =
  1124. selectedPlaylist.songs[
  1125. Math.floor(
  1126. Math.random() * selectedPlaylist.songs.length
  1127. )
  1128. ];
  1129. if (selectedSong.youtubeId) {
  1130. this.updateAutoRequestLock(true);
  1131. this.socket.dispatch(
  1132. "stations.addToQueue",
  1133. this.station._id,
  1134. selectedSong.youtubeId,
  1135. data => {
  1136. this.updateAutoRequestLock(false);
  1137. if (data.status !== "success") {
  1138. setTimeout(
  1139. () => {
  1140. this.autoRequestSong();
  1141. },
  1142. data.message ===
  1143. "That song is already in the queue."
  1144. ? 5000
  1145. : 1000
  1146. );
  1147. }
  1148. }
  1149. );
  1150. }
  1151. }
  1152. }
  1153. },
  1154. removeFromQueue(youtubeId) {
  1155. window.socket.dispatch(
  1156. "stations.removeFromQueue",
  1157. this.station._id,
  1158. youtubeId,
  1159. res => {
  1160. if (res.status === "success") {
  1161. new Toast("Successfully removed song from the queue.");
  1162. } else new Toast(res.message);
  1163. }
  1164. );
  1165. },
  1166. setNextCurrentSong(nextCurrentSong, skipSkipCheck = false) {
  1167. this.nextCurrentSong = nextCurrentSong;
  1168. // If skipSkipCheck is true, it won't try to skip the song
  1169. if (this.getTimeRemaining() <= 0 && !skipSkipCheck) {
  1170. this.skipSong();
  1171. }
  1172. },
  1173. skipSong() {
  1174. if (this.nextCurrentSong && this.nextCurrentSong.currentSong) {
  1175. const songsList = this.songsList.concat([]);
  1176. if (
  1177. songsList.length > 0 &&
  1178. songsList[0].youtubeId ===
  1179. this.nextCurrentSong.currentSong.youtubeId
  1180. ) {
  1181. songsList.splice(0, 1);
  1182. this.updateSongsList(songsList);
  1183. }
  1184. this.setCurrentSong(this.nextCurrentSong);
  1185. } else {
  1186. this.setCurrentSong({
  1187. currentSong: null,
  1188. startedAt: 0,
  1189. paused: this.stationPaused,
  1190. timePaused: 0,
  1191. pausedAt: 0
  1192. });
  1193. }
  1194. },
  1195. setCurrentSong(data) {
  1196. const { currentSong, startedAt, paused, timePaused, pausedAt } =
  1197. data;
  1198. if (currentSong) {
  1199. if (!currentSong.skipDuration || currentSong.skipDuration < 0)
  1200. currentSong.skipDuration = 0;
  1201. if (!currentSong.duration || currentSong.duration < 0)
  1202. currentSong.duration = 0;
  1203. }
  1204. this.updateCurrentSong(currentSong || {});
  1205. let nextSong = null;
  1206. if (this.songsList[0])
  1207. nextSong = this.songsList[0].youtubeId
  1208. ? this.songsList[0]
  1209. : null;
  1210. this.updateNextSong(nextSong);
  1211. this.setNextCurrentSong(
  1212. {
  1213. currentSong: null,
  1214. startedAt: 0,
  1215. paused,
  1216. timePaused: 0,
  1217. pausedAt: 0
  1218. },
  1219. true
  1220. );
  1221. clearTimeout(window.stationNextSongTimeout);
  1222. if (this.mediasession) this.updateMediaSessionData(currentSong);
  1223. this.startedAt = startedAt;
  1224. this.updateStationPaused(paused);
  1225. this.timePaused = timePaused;
  1226. this.pausedAt = pausedAt;
  1227. if (currentSong) {
  1228. this.updateNoSong(false);
  1229. if (!this.playerReady) this.youtubeReady();
  1230. else this.playVideo();
  1231. // If the station is playing and the backend is not connected, set the next song to skip to after this song and set a timer to skip
  1232. if (!this.stationPaused && !this.socketConnected) {
  1233. if (this.nextSong)
  1234. this.setNextCurrentSong(
  1235. {
  1236. currentSong: this.nextSong,
  1237. startedAt: Date.now() + this.getTimeRemaining(),
  1238. paused: false,
  1239. timePaused: 0
  1240. },
  1241. true
  1242. );
  1243. else
  1244. this.setNextCurrentSong(
  1245. {
  1246. currentSong: null,
  1247. startedAt: 0,
  1248. paused: false,
  1249. timePaused: 0,
  1250. pausedAt: 0
  1251. },
  1252. true
  1253. );
  1254. window.stationNextSongTimeout = setTimeout(() => {
  1255. if (
  1256. !this.noSong &&
  1257. this.currentSong._id === currentSong._id
  1258. )
  1259. this.skipSong("window.stationNextSongTimeout 1");
  1260. }, this.getTimeRemaining());
  1261. }
  1262. const currentSongId = this.currentSong._id;
  1263. this.socket.dispatch(
  1264. "stations.getSkipVotes",
  1265. this.station._id,
  1266. currentSongId,
  1267. res => {
  1268. if (res.status === "success") {
  1269. const { skipVotes, skipVotesCurrent } = res.data;
  1270. if (
  1271. !this.noSong &&
  1272. this.currentSong._id === currentSongId
  1273. ) {
  1274. this.updateCurrentSongSkipVotes({
  1275. skipVotes,
  1276. skipVotesCurrent
  1277. });
  1278. }
  1279. }
  1280. }
  1281. );
  1282. this.socket.dispatch(
  1283. "songs.getSongRatings",
  1284. currentSong._id,
  1285. res => {
  1286. if (currentSong._id === this.currentSong._id) {
  1287. const { likes, dislikes } = res.data;
  1288. this.updateCurrentSongRatings({ likes, dislikes });
  1289. }
  1290. }
  1291. );
  1292. if (this.loggedIn) {
  1293. this.socket.dispatch(
  1294. "songs.getOwnSongRatings",
  1295. currentSong.youtubeId,
  1296. res => {
  1297. console.log("getOwnSongRatings", res);
  1298. if (
  1299. res.status === "success" &&
  1300. this.currentSong.youtubeId ===
  1301. res.data.youtubeId
  1302. ) {
  1303. this.updateOwnCurrentSongRatings(res.data);
  1304. if (
  1305. this.autoSkipDisliked &&
  1306. res.data.disliked === true
  1307. ) {
  1308. this.voteSkipStation();
  1309. new Toast(
  1310. "Automatically voted to skip disliked song."
  1311. );
  1312. }
  1313. }
  1314. }
  1315. );
  1316. }
  1317. } else {
  1318. if (this.playerReady) this.player.stopVideo();
  1319. this.updateNoSong(true);
  1320. }
  1321. this.calculateTimeElapsed();
  1322. this.resizeSeekerbar();
  1323. },
  1324. youtubeReady() {
  1325. if (!this.player) {
  1326. ms.setYTReady(false);
  1327. this.player = new window.YT.Player("stationPlayer", {
  1328. height: 270,
  1329. width: 480,
  1330. videoId: this.currentSong.youtubeId,
  1331. host: "https://www.youtube-nocookie.com",
  1332. startSeconds:
  1333. this.getTimeElapsed() / 1000 +
  1334. this.currentSong.skipDuration,
  1335. playerVars: {
  1336. controls: 0,
  1337. iv_load_policy: 3,
  1338. rel: 0,
  1339. showinfo: 0,
  1340. disablekb: 1,
  1341. playsinline: 1
  1342. },
  1343. events: {
  1344. onReady: () => {
  1345. this.playerReady = true;
  1346. ms.setYTReady(true);
  1347. let volume = parseFloat(
  1348. localStorage.getItem("volume")
  1349. );
  1350. volume = typeof volume === "number" ? volume : 20;
  1351. this.player.setVolume(volume);
  1352. if (volume > 0) this.player.unMute();
  1353. if (this.muted) this.player.mute();
  1354. this.playVideo();
  1355. // on ios, playback will be forcibly paused locally
  1356. if (this.isApple) {
  1357. this.updateLocalPaused(true);
  1358. new Toast(
  1359. `Please click play manually to use ${this.sitename} on iOS.`
  1360. );
  1361. }
  1362. },
  1363. onError: err => {
  1364. console.log("error with youtube video", err);
  1365. if (err.data === 150 && this.loggedIn) {
  1366. new Toast(
  1367. "Automatically voted to skip as this song isn't available for you."
  1368. );
  1369. // automatically vote to skip
  1370. this.voteSkipStation();
  1371. // persistent message while song is playing
  1372. const persistentToast = new Toast({
  1373. content:
  1374. "This song is unavailable for you, but is playing for everyone else.",
  1375. persistent: true
  1376. });
  1377. // save current song id
  1378. const erroredYoutubeId =
  1379. this.currentSong.youtubeId;
  1380. this.persistentToasts.push({
  1381. toast: persistentToast,
  1382. checkIfCanRemove: () => {
  1383. if (
  1384. this.currentSong.youtubeId !==
  1385. erroredYoutubeId
  1386. ) {
  1387. persistentToast.destroy();
  1388. return true;
  1389. }
  1390. return false;
  1391. }
  1392. });
  1393. } else {
  1394. new Toast(
  1395. "There has been an error with the YouTube Embed"
  1396. );
  1397. }
  1398. },
  1399. onStateChange: event => {
  1400. if (
  1401. event.data === window.YT.PlayerState.PLAYING &&
  1402. this.videoLoading === true
  1403. ) {
  1404. this.videoLoading = false;
  1405. this.player.seekTo(
  1406. this.getTimeElapsed() / 1000 +
  1407. this.currentSong.skipDuration,
  1408. true
  1409. );
  1410. this.canAutoplay = true;
  1411. if (this.localPaused || this.stationPaused)
  1412. this.player.pauseVideo();
  1413. } else if (
  1414. event.data === window.YT.PlayerState.PLAYING &&
  1415. (this.localPaused || this.stationPaused)
  1416. ) {
  1417. this.player.seekTo(
  1418. this.timeBeforePause / 1000,
  1419. true
  1420. );
  1421. this.player.pauseVideo();
  1422. } else if (
  1423. event.data === window.YT.PlayerState.PLAYING &&
  1424. this.seeking === true
  1425. )
  1426. this.seeking = false;
  1427. if (
  1428. event.data === window.YT.PlayerState.PAUSED &&
  1429. !this.localPaused &&
  1430. !this.stationPaused &&
  1431. !this.noSong &&
  1432. this.player.getDuration() / 1000 <
  1433. this.currentSong.duration
  1434. ) {
  1435. this.player.seekTo(
  1436. this.getTimeElapsed() / 1000 +
  1437. this.currentSong.skipDuration,
  1438. true
  1439. );
  1440. this.player.playVideo();
  1441. }
  1442. }
  1443. }
  1444. });
  1445. }
  1446. },
  1447. getTimeElapsed() {
  1448. if (this.currentSong) {
  1449. let { timePaused } = this;
  1450. if (this.stationPaused)
  1451. timePaused += Date.currently() - this.pausedAt;
  1452. return Date.currently() - this.startedAt - timePaused;
  1453. }
  1454. return 0;
  1455. },
  1456. getTimeRemaining() {
  1457. if (this.currentSong) {
  1458. return this.currentSong.duration * 1000 - this.getTimeElapsed();
  1459. }
  1460. return 0;
  1461. },
  1462. playVideo() {
  1463. if (this.playerReady) {
  1464. this.videoLoading = true;
  1465. this.player.loadVideoById(
  1466. this.currentSong.youtubeId,
  1467. this.getTimeElapsed() / 1000 + this.currentSong.skipDuration
  1468. );
  1469. if (window.stationInterval !== 0)
  1470. clearInterval(window.stationInterval);
  1471. window.stationInterval = setInterval(() => {
  1472. if (!this.stationPaused) {
  1473. this.resizeSeekerbar();
  1474. this.calculateTimeElapsed();
  1475. }
  1476. }, 150);
  1477. }
  1478. },
  1479. resizeSeekerbar() {
  1480. this.seekerbarPercentage = parseFloat(
  1481. (this.getTimeElapsed() / 1000 / this.currentSong.duration) * 100
  1482. );
  1483. },
  1484. calculateTimeElapsed() {
  1485. if (
  1486. this.playerReady &&
  1487. !this.noSong &&
  1488. this.currentSong &&
  1489. this.player.getPlayerState() === -1
  1490. ) {
  1491. if (!this.canAutoplay) {
  1492. if (
  1493. Date.now() - this.lastTimeRequestedIfCanAutoplay >
  1494. 2000
  1495. ) {
  1496. this.lastTimeRequestedIfCanAutoplay = Date.now();
  1497. canAutoPlay.video().then(({ result }) => {
  1498. if (result) {
  1499. this.attemptsToPlayVideo = 0;
  1500. this.canAutoplay = true;
  1501. } else {
  1502. this.canAutoplay = false;
  1503. }
  1504. });
  1505. }
  1506. } else {
  1507. this.player.playVideo();
  1508. this.attemptsToPlayVideo += 1;
  1509. }
  1510. }
  1511. if (
  1512. !this.stationPaused &&
  1513. !this.localPaused &&
  1514. this.playerReady &&
  1515. !this.isApple
  1516. ) {
  1517. const timeElapsed = this.getTimeElapsed();
  1518. const currentPlayerTime =
  1519. Math.max(
  1520. this.player.getCurrentTime() -
  1521. this.currentSong.skipDuration,
  1522. 0
  1523. ) * 1000;
  1524. const difference = timeElapsed - currentPlayerTime;
  1525. let playbackRate = 1;
  1526. if (difference < -2000) {
  1527. if (!this.seeking) {
  1528. this.seeking = true;
  1529. this.player.seekTo(
  1530. this.getTimeElapsed() / 1000 +
  1531. this.currentSong.skipDuration
  1532. );
  1533. }
  1534. } else if (difference < -200) {
  1535. playbackRate = 0.8;
  1536. } else if (difference < -50) {
  1537. playbackRate = 0.9;
  1538. } else if (difference < -25) {
  1539. playbackRate = 0.95;
  1540. } else if (difference > 2000) {
  1541. if (!this.seeking) {
  1542. this.seeking = true;
  1543. this.player.seekTo(
  1544. this.getTimeElapsed() / 1000 +
  1545. this.currentSong.skipDuration
  1546. );
  1547. }
  1548. } else if (difference > 200) {
  1549. playbackRate = 1.2;
  1550. } else if (difference > 50) {
  1551. playbackRate = 1.1;
  1552. } else if (difference > 25) {
  1553. playbackRate = 1.05;
  1554. } else if (this.player.getPlaybackRate !== 1.0) {
  1555. this.player.setPlaybackRate(1.0);
  1556. }
  1557. if (this.playbackRate !== playbackRate) {
  1558. this.player.setPlaybackRate(playbackRate);
  1559. this.playbackRate = playbackRate;
  1560. }
  1561. }
  1562. let { timePaused } = this;
  1563. if (this.stationPaused)
  1564. timePaused += Date.currently() - this.pausedAt;
  1565. const duration =
  1566. (Date.currently() - this.startedAt - timePaused) / 1000;
  1567. const songDuration = this.currentSong.duration;
  1568. if (songDuration <= duration) this.player.pauseVideo();
  1569. if (duration <= songDuration)
  1570. this.timeElapsed = utils.formatTime(duration);
  1571. },
  1572. changeVolume() {
  1573. const volume = this.volumeSliderValue;
  1574. localStorage.setItem("volume", volume);
  1575. if (this.playerReady) {
  1576. this.player.setVolume(volume);
  1577. if (volume > 0) {
  1578. this.player.unMute();
  1579. localStorage.setItem("muted", false);
  1580. this.muted = false;
  1581. }
  1582. }
  1583. },
  1584. resumeLocalStation() {
  1585. this.updateLocalPaused(false);
  1586. if (!this.stationPaused) this.resumeLocalPlayer();
  1587. },
  1588. pauseLocalStation() {
  1589. this.updateLocalPaused(true);
  1590. this.pauseLocalPlayer();
  1591. },
  1592. resumeLocalPlayer() {
  1593. if (this.mediasession)
  1594. this.updateMediaSessionData(this.currentSong);
  1595. if (!this.noSong) {
  1596. if (this.playerReady) {
  1597. this.player.seekTo(
  1598. this.getTimeElapsed() / 1000 +
  1599. this.currentSong.skipDuration
  1600. );
  1601. this.player.playVideo();
  1602. }
  1603. }
  1604. },
  1605. pauseLocalPlayer() {
  1606. if (this.mediasession)
  1607. this.updateMediaSessionData(this.currentSong);
  1608. if (!this.noSong) {
  1609. this.timeBeforePause = this.getTimeElapsed();
  1610. if (this.playerReady) this.player.pauseVideo();
  1611. }
  1612. },
  1613. skipStation() {
  1614. this.socket.dispatch(
  1615. "stations.forceSkip",
  1616. this.station._id,
  1617. data => {
  1618. if (data.status !== "success")
  1619. new Toast(`Error: ${data.message}`);
  1620. else
  1621. new Toast(
  1622. "Successfully skipped the station's current song."
  1623. );
  1624. }
  1625. );
  1626. },
  1627. voteSkipStation() {
  1628. this.socket.dispatch(
  1629. "stations.voteSkip",
  1630. this.station._id,
  1631. data => {
  1632. if (data.status !== "success")
  1633. new Toast(`Error: ${data.message}`);
  1634. else
  1635. new Toast(
  1636. "Successfully voted to skip the current song."
  1637. );
  1638. }
  1639. );
  1640. },
  1641. resumeStation() {
  1642. this.socket.dispatch("stations.resume", this.station._id, data => {
  1643. if (data.status !== "success")
  1644. new Toast(`Error: ${data.message}`);
  1645. else new Toast("Successfully resumed the station.");
  1646. });
  1647. },
  1648. pauseStation() {
  1649. this.socket.dispatch("stations.pause", this.station._id, data => {
  1650. if (data.status !== "success")
  1651. new Toast(`Error: ${data.message}`);
  1652. else new Toast("Successfully paused the station.");
  1653. });
  1654. },
  1655. toggleMute() {
  1656. if (this.playerReady) {
  1657. const previousVolume = parseFloat(
  1658. localStorage.getItem("volume")
  1659. );
  1660. const volume =
  1661. this.player.getVolume() <= 0 ? previousVolume : 0;
  1662. this.muted = !this.muted;
  1663. localStorage.setItem("muted", this.muted);
  1664. this.volumeSliderValue = volume;
  1665. this.player.setVolume(volume);
  1666. if (!this.muted) localStorage.setItem("volume", volume);
  1667. }
  1668. },
  1669. increaseVolume() {
  1670. if (this.playerReady) {
  1671. const previousVolume = parseFloat(
  1672. localStorage.getItem("volume")
  1673. );
  1674. let volume = previousVolume + 5;
  1675. if (previousVolume === 0) {
  1676. this.muted = false;
  1677. localStorage.setItem("muted", false);
  1678. }
  1679. if (volume > 100) volume = 100;
  1680. this.volumeSliderValue = volume;
  1681. this.player.setVolume(volume);
  1682. localStorage.setItem("volume", volume);
  1683. }
  1684. },
  1685. toggleLike() {
  1686. if (this.currentSong.liked)
  1687. this.socket.dispatch(
  1688. "songs.unlike",
  1689. this.currentSong.youtubeId,
  1690. res => {
  1691. if (res.status !== "success")
  1692. new Toast(`Error: ${res.message}`);
  1693. }
  1694. );
  1695. else
  1696. this.socket.dispatch(
  1697. "songs.like",
  1698. this.currentSong.youtubeId,
  1699. res => {
  1700. if (res.status !== "success")
  1701. new Toast(`Error: ${res.message}`);
  1702. }
  1703. );
  1704. },
  1705. toggleDislike() {
  1706. if (this.currentSong.disliked)
  1707. return this.socket.dispatch(
  1708. "songs.undislike",
  1709. this.currentSong.youtubeId,
  1710. res => {
  1711. if (res.status !== "success")
  1712. new Toast(`Error: ${res.message}`);
  1713. }
  1714. );
  1715. return this.socket.dispatch(
  1716. "songs.dislike",
  1717. this.currentSong.youtubeId,
  1718. res => {
  1719. if (res.status !== "success")
  1720. new Toast(`Error: ${res.message}`);
  1721. }
  1722. );
  1723. },
  1724. togglePlayerDebugBox() {
  1725. this.$refs.playerDebugBox.toggleBox();
  1726. },
  1727. resetPlayerDebugBox() {
  1728. this.$refs.playerDebugBox.resetBox();
  1729. },
  1730. toggleKeyboardShortcutsHelper() {
  1731. this.$refs.keyboardShortcutsHelper.toggleBox();
  1732. },
  1733. resetKeyboardShortcutsHelper() {
  1734. this.$refs.keyboardShortcutsHelper.resetBox();
  1735. },
  1736. join() {
  1737. this.socket.dispatch(
  1738. "stations.join",
  1739. this.stationIdentifier,
  1740. res => {
  1741. if (res.status === "success") {
  1742. setTimeout(() => {
  1743. this.loading = false;
  1744. }, 1000); // prevents popping in of youtube embed etc.
  1745. const {
  1746. _id,
  1747. displayName,
  1748. name,
  1749. description,
  1750. privacy,
  1751. owner,
  1752. autofill,
  1753. blacklist,
  1754. type,
  1755. isFavorited,
  1756. theme,
  1757. requests
  1758. } = res.data;
  1759. // change url to use station name instead of station id
  1760. if (name !== this.stationIdentifier) {
  1761. // eslint-disable-next-line no-restricted-globals
  1762. this.$router.replace(name);
  1763. }
  1764. this.joinStation({
  1765. _id,
  1766. name,
  1767. displayName,
  1768. description,
  1769. privacy,
  1770. owner,
  1771. autofill,
  1772. blacklist,
  1773. type,
  1774. isFavorited,
  1775. theme,
  1776. requests
  1777. });
  1778. document.getElementsByTagName(
  1779. "html"
  1780. )[0].style.cssText = `--primary-color: var(--${res.data.theme})`;
  1781. this.setCurrentSong({
  1782. currentSong: res.data.currentSong,
  1783. startedAt: res.data.startedAt,
  1784. paused: res.data.paused,
  1785. timePaused: res.data.timePaused,
  1786. pausedAt: res.data.pausedAt
  1787. });
  1788. this.updateUserCount(res.data.userCount);
  1789. this.updateUsers(res.data.users);
  1790. this.socket.dispatch(
  1791. "stations.getStationAutofillPlaylistsById",
  1792. this.station._id,
  1793. res => {
  1794. if (res.status === "success") {
  1795. this.setAutofillPlaylists(
  1796. res.data.playlists
  1797. );
  1798. }
  1799. }
  1800. );
  1801. this.socket.dispatch(
  1802. "stations.getStationBlacklistById",
  1803. this.station._id,
  1804. res => {
  1805. if (res.status === "success") {
  1806. this.setBlacklist(res.data.playlists);
  1807. }
  1808. }
  1809. );
  1810. this.socket.dispatch("stations.getQueue", _id, res => {
  1811. if (res.status === "success") {
  1812. const { queue } = res.data;
  1813. this.updateSongsList(queue);
  1814. const [nextSong] = queue;
  1815. this.updateNextSong(nextSong);
  1816. }
  1817. });
  1818. if (this.isOwnerOrAdmin()) {
  1819. keyboardShortcuts.registerShortcut(
  1820. "station.pauseResume",
  1821. {
  1822. keyCode: 32, // Spacebar
  1823. shift: false,
  1824. ctrl: true,
  1825. preventDefault: true,
  1826. handler: () => {
  1827. if (this.aModalIsOpen) return;
  1828. if (this.stationPaused)
  1829. this.resumeStation();
  1830. else this.pauseStation();
  1831. }
  1832. }
  1833. );
  1834. keyboardShortcuts.registerShortcut(
  1835. "station.skipStation",
  1836. {
  1837. keyCode: 39, // Right arrow key
  1838. shift: false,
  1839. ctrl: true,
  1840. preventDefault: true,
  1841. handler: () => {
  1842. if (this.aModalIsOpen) return;
  1843. this.skipStation();
  1844. }
  1845. }
  1846. );
  1847. }
  1848. keyboardShortcuts.registerShortcut(
  1849. "station.lowerVolumeLarge",
  1850. {
  1851. keyCode: 40, // Down arrow key
  1852. shift: false,
  1853. ctrl: true,
  1854. preventDefault: true,
  1855. handler: () => {
  1856. if (this.aModalIsOpen) return;
  1857. this.volumeSliderValue -= 10;
  1858. this.changeVolume();
  1859. }
  1860. }
  1861. );
  1862. keyboardShortcuts.registerShortcut(
  1863. "station.lowerVolumeSmall",
  1864. {
  1865. keyCode: 40, // Down arrow key
  1866. shift: true,
  1867. ctrl: true,
  1868. preventDefault: true,
  1869. handler: () => {
  1870. if (this.aModalIsOpen) return;
  1871. this.volumeSliderValue -= 1;
  1872. this.changeVolume();
  1873. }
  1874. }
  1875. );
  1876. keyboardShortcuts.registerShortcut(
  1877. "station.increaseVolumeLarge",
  1878. {
  1879. keyCode: 38, // Up arrow key
  1880. shift: false,
  1881. ctrl: true,
  1882. preventDefault: true,
  1883. handler: () => {
  1884. if (this.aModalIsOpen) return;
  1885. this.volumeSliderValue += 10;
  1886. this.changeVolume();
  1887. }
  1888. }
  1889. );
  1890. keyboardShortcuts.registerShortcut(
  1891. "station.increaseVolumeSmall",
  1892. {
  1893. keyCode: 38, // Up arrow key
  1894. shift: true,
  1895. ctrl: true,
  1896. preventDefault: true,
  1897. handler: () => {
  1898. if (this.aModalIsOpen) return;
  1899. this.volumeSliderValue += 1;
  1900. this.changeVolume();
  1901. }
  1902. }
  1903. );
  1904. keyboardShortcuts.registerShortcut(
  1905. "station.toggleDebug",
  1906. {
  1907. keyCode: 68, // D key
  1908. shift: false,
  1909. ctrl: true,
  1910. preventDefault: true,
  1911. handler: () => {
  1912. if (this.aModalIsOpen) return;
  1913. this.togglePlayerDebugBox();
  1914. }
  1915. }
  1916. );
  1917. keyboardShortcuts.registerShortcut(
  1918. "station.toggleKeyboardShortcutsHelper",
  1919. {
  1920. keyCode: 191, // '/' key
  1921. ctrl: true,
  1922. preventDefault: true,
  1923. handler: () => {
  1924. if (this.aModalIsOpen) return;
  1925. this.toggleKeyboardShortcutsHelper();
  1926. }
  1927. }
  1928. );
  1929. keyboardShortcuts.registerShortcut(
  1930. "station.resetKeyboardShortcutsHelper",
  1931. {
  1932. keyCode: 191, // '/' key
  1933. ctrl: true,
  1934. shift: true,
  1935. preventDefault: true,
  1936. handler: () => {
  1937. if (this.aModalIsOpen) return;
  1938. this.resetKeyboardShortcutsHelper();
  1939. }
  1940. }
  1941. );
  1942. // UNIX client time before ping
  1943. const beforePing = Date.now();
  1944. this.socket.dispatch("apis.ping", res => {
  1945. if (res.status === "success") {
  1946. // UNIX client time after ping
  1947. const afterPing = Date.now();
  1948. // Average time in MS it took between the server responding and the client receiving
  1949. const connectionLatency =
  1950. (afterPing - beforePing) / 2;
  1951. console.log(
  1952. connectionLatency,
  1953. beforePing - afterPing
  1954. );
  1955. // UNIX server time
  1956. const serverDate = res.data.date;
  1957. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  1958. const difference =
  1959. serverDate + connectionLatency - afterPing;
  1960. console.log("Difference: ", difference);
  1961. if (difference > 3000 || difference < -3000) {
  1962. console.log(
  1963. "System time difference is bigger than 3 seconds."
  1964. );
  1965. }
  1966. this.systemDifference = difference;
  1967. }
  1968. });
  1969. } else {
  1970. this.loading = false;
  1971. this.exists = false;
  1972. }
  1973. }
  1974. );
  1975. },
  1976. favoriteStation() {
  1977. this.socket.dispatch(
  1978. "stations.favoriteStation",
  1979. this.station._id,
  1980. res => {
  1981. if (res.status === "success") {
  1982. new Toast("Successfully favorited station.");
  1983. } else new Toast(res.message);
  1984. }
  1985. );
  1986. },
  1987. unfavoriteStation() {
  1988. this.socket.dispatch(
  1989. "stations.unfavoriteStation",
  1990. this.station._id,
  1991. res => {
  1992. if (res.status === "success") {
  1993. new Toast("Successfully unfavorited station.");
  1994. } else new Toast(res.message);
  1995. }
  1996. );
  1997. },
  1998. sendActivityWatchVideoData() {
  1999. if (!this.stationPaused && !this.localPaused && !this.noSong) {
  2000. if (this.activityWatchVideoLastStatus !== "playing") {
  2001. this.activityWatchVideoLastStatus = "playing";
  2002. this.activityWatchVideoLastStartDuration =
  2003. this.currentSong.skipDuration + this.getTimeElapsed();
  2004. }
  2005. if (
  2006. this.activityWatchVideoLastYouTubeId !==
  2007. this.currentSong.youtubeId
  2008. ) {
  2009. this.activityWatchVideoLastYouTubeId =
  2010. this.currentSong.youtubeId;
  2011. this.activityWatchVideoLastStartDuration =
  2012. this.currentSong.skipDuration + this.getTimeElapsed();
  2013. }
  2014. const videoData = {
  2015. title: this.currentSong ? this.currentSong.title : null,
  2016. artists:
  2017. this.currentSong && this.currentSong.artists
  2018. ? this.currentSong.artists.join(", ")
  2019. : null,
  2020. youtubeId: this.currentSong.youtubeId,
  2021. muted: this.muted,
  2022. volume: this.volumeSliderValue,
  2023. startedDuration:
  2024. this.activityWatchVideoLastStartDuration <= 0
  2025. ? 0
  2026. : Math.floor(
  2027. this.activityWatchVideoLastStartDuration /
  2028. 1000
  2029. ),
  2030. source: `station#${this.station.name}`,
  2031. hostname: window.location.hostname
  2032. };
  2033. aw.sendVideoData(videoData);
  2034. } else {
  2035. this.activityWatchVideoLastStatus = "not_playing";
  2036. }
  2037. },
  2038. ...mapActions("modalVisibility", ["openModal"]),
  2039. ...mapActions("station", [
  2040. "joinStation",
  2041. "leaveStation",
  2042. "updateStation",
  2043. "updateUserCount",
  2044. "updateUsers",
  2045. "updateCurrentSong",
  2046. "updateNextSong",
  2047. "updateSongsList",
  2048. "repositionSongInList",
  2049. "updateStationPaused",
  2050. "updateLocalPaused",
  2051. "updateNoSong",
  2052. "updateIfStationIsFavorited",
  2053. "setAutofillPlaylists",
  2054. "setBlacklist",
  2055. "updateCurrentSongRatings",
  2056. "updateOwnCurrentSongRatings",
  2057. "updateCurrentSongSkipVotes",
  2058. "updateAutoRequestLock"
  2059. ]),
  2060. ...mapActions("modals/editSong", ["stopVideo"])
  2061. }
  2062. };
  2063. </script>
  2064. <style lang="less">
  2065. #stationPlayer {
  2066. position: absolute;
  2067. top: 0;
  2068. left: 0;
  2069. width: 100%;
  2070. height: 100%;
  2071. }
  2072. #currently-playing-container,
  2073. #next-up-container {
  2074. .song-item {
  2075. .thumbnail {
  2076. min-width: 130px;
  2077. width: 130px;
  2078. height: 130px;
  2079. }
  2080. }
  2081. }
  2082. #control-bar-container
  2083. #right-buttons
  2084. .tippy-box[data-theme~="dropdown"]
  2085. .nav-dropdown-items {
  2086. padding-bottom: 0 !important;
  2087. }
  2088. </style>
  2089. <style lang="less" scoped>
  2090. #page-loader-container {
  2091. height: inherit;
  2092. #page-loader-content {
  2093. height: inherit;
  2094. position: absolute;
  2095. max-width: 100%;
  2096. width: 1800px;
  2097. transform: translateX(-50%);
  2098. left: 50%;
  2099. }
  2100. #page-loader-layout {
  2101. height: inherit;
  2102. width: 100%;
  2103. }
  2104. }
  2105. #mobile-progress-animation {
  2106. width: 50px;
  2107. animation: rotate 0.8s infinite linear;
  2108. border: 8px solid var(--primary-color);
  2109. border-right-color: transparent;
  2110. border-radius: 50%;
  2111. height: 50px;
  2112. position: absolute;
  2113. top: 50%;
  2114. left: 50%;
  2115. display: none;
  2116. }
  2117. @keyframes rotate {
  2118. 0% {
  2119. transform: rotate(0deg);
  2120. }
  2121. 100% {
  2122. transform: rotate(360deg);
  2123. }
  2124. }
  2125. .nav,
  2126. .button.is-primary {
  2127. background-color: var(--primary-color) !important;
  2128. }
  2129. .button.is-primary:hover,
  2130. .button.is-primary:focus {
  2131. filter: brightness(90%);
  2132. }
  2133. .night-mode {
  2134. #currently-playing-container,
  2135. #next-up-container,
  2136. #control-bar-container,
  2137. .quadrant:not(#sidebar-container),
  2138. .player-container {
  2139. background-color: var(--dark-grey-3) !important;
  2140. }
  2141. #video-container,
  2142. #control-bar-container,
  2143. .quadrant:not(#sidebar-container),
  2144. .player-container {
  2145. border: 0 !important;
  2146. }
  2147. #seeker-bar-container {
  2148. background-color: var(--dark-grey-3) !important;
  2149. }
  2150. #dropdown-toggle {
  2151. background-color: var(--dark-grey-2) !important;
  2152. border: 0;
  2153. i {
  2154. color: var(--white);
  2155. }
  2156. }
  2157. }
  2158. #station-outer-container {
  2159. margin: 0 auto;
  2160. padding: 20px 40px;
  2161. min-height: calc(100vh - 64px);
  2162. width: 100%;
  2163. max-width: 1800px;
  2164. display: flex;
  2165. #station-inner-container {
  2166. width: 100%;
  2167. min-height: calc(100vh - 428px);
  2168. display: flex;
  2169. flex-direction: row;
  2170. flex-wrap: wrap;
  2171. .row {
  2172. display: flex;
  2173. flex-direction: row;
  2174. max-width: 100%;
  2175. }
  2176. .column {
  2177. display: flex;
  2178. flex-direction: column;
  2179. }
  2180. .quadrant {
  2181. border-radius: @border-radius;
  2182. margin: 10px;
  2183. overflow: hidden;
  2184. }
  2185. .quadrant:not(#sidebar-container) {
  2186. background-color: var(--white);
  2187. border: 1px solid var(--light-grey-3);
  2188. }
  2189. #station-left-column,
  2190. #station-right-column {
  2191. padding: 0;
  2192. }
  2193. #current-next-row {
  2194. display: flex;
  2195. flex-direction: row;
  2196. #currently-playing-container,
  2197. #next-up-container {
  2198. overflow: hidden;
  2199. flex-basis: 50%;
  2200. .song-item {
  2201. border: unset;
  2202. }
  2203. .nothing-here-text {
  2204. height: 100%;
  2205. }
  2206. }
  2207. > div:only-child {
  2208. flex: 1 !important;
  2209. flex-basis: 100% !important;
  2210. }
  2211. }
  2212. .player-container {
  2213. height: inherit;
  2214. background-color: var(--white);
  2215. display: flex;
  2216. flex-direction: column;
  2217. border: 1px solid var(--light-grey-3);
  2218. border-radius: @border-radius;
  2219. overflow: hidden;
  2220. &.nothing-here-text {
  2221. margin: 10px;
  2222. flex: 1;
  2223. min-height: 487px;
  2224. }
  2225. #video-container {
  2226. position: relative;
  2227. padding-bottom: 56.25%; /* proportion value to aspect ratio 16:9 (9 / 16 = 0.5625 or 56.25%) */
  2228. height: 0;
  2229. overflow: hidden;
  2230. .player-cannot-autoplay {
  2231. position: relative;
  2232. width: 100%;
  2233. height: 100%;
  2234. bottom: calc(100% + 5px);
  2235. background: var(--primary-color);
  2236. display: flex;
  2237. align-items: center;
  2238. justify-content: center;
  2239. p {
  2240. color: var(--white);
  2241. font-size: 26px;
  2242. text-align: center;
  2243. }
  2244. }
  2245. }
  2246. #seeker-bar-container {
  2247. background-color: var(--white);
  2248. position: relative;
  2249. height: 7px;
  2250. display: block;
  2251. width: 100%;
  2252. #seeker-bar {
  2253. background-color: var(--primary-color);
  2254. top: 0;
  2255. left: 0;
  2256. bottom: 0;
  2257. position: absolute;
  2258. width: 100%;
  2259. }
  2260. .seeker-bar-cover {
  2261. position: absolute;
  2262. top: 0;
  2263. right: 0;
  2264. bottom: 0;
  2265. background-color: inherit;
  2266. }
  2267. }
  2268. #control-bar-container {
  2269. display: flex;
  2270. justify-content: space-around;
  2271. padding: 10px 0;
  2272. width: 100%;
  2273. background: var(--white);
  2274. flex-direction: column;
  2275. flex-flow: wrap;
  2276. .button:not(#dropdown-toggle) {
  2277. width: 75px;
  2278. }
  2279. #left-buttons,
  2280. #right-buttons {
  2281. margin: 3px;
  2282. }
  2283. #left-buttons {
  2284. display: flex;
  2285. .button:not(:first-of-type) {
  2286. margin-left: 5px;
  2287. }
  2288. .disabled {
  2289. filter: grayscale(0.4);
  2290. }
  2291. }
  2292. #duration {
  2293. margin: 3px;
  2294. display: flex;
  2295. align-items: center;
  2296. p {
  2297. font-size: 22px;
  2298. /** prevents duration width slightly varying and shifting other controls slightly */
  2299. width: 150px;
  2300. text-align: center;
  2301. }
  2302. }
  2303. #volume-control {
  2304. margin: 3px;
  2305. margin-top: 0;
  2306. display: flex;
  2307. align-items: center;
  2308. cursor: pointer;
  2309. .volume-slider {
  2310. width: 100%;
  2311. padding: 0 15px;
  2312. background: transparent;
  2313. min-width: 100px;
  2314. }
  2315. input[type="range"] {
  2316. -webkit-appearance: none;
  2317. margin: 7.3px 0;
  2318. }
  2319. input[type="range"]:focus {
  2320. outline: none;
  2321. }
  2322. input[type="range"]::-webkit-slider-runnable-track {
  2323. width: 100%;
  2324. height: 5.2px;
  2325. cursor: pointer;
  2326. box-shadow: 0;
  2327. background: var(--light-grey-3);
  2328. border-radius: @border-radius;
  2329. border: 0;
  2330. }
  2331. input[type="range"]::-webkit-slider-thumb {
  2332. box-shadow: 0;
  2333. border: 0;
  2334. height: 19px;
  2335. width: 19px;
  2336. border-radius: 100%;
  2337. background: var(--primary-color);
  2338. cursor: pointer;
  2339. -webkit-appearance: none;
  2340. margin-top: -6.5px;
  2341. }
  2342. input[type="range"]::-moz-range-track {
  2343. width: 100%;
  2344. height: 5.2px;
  2345. cursor: pointer;
  2346. box-shadow: 0;
  2347. background: var(--light-grey-3);
  2348. border-radius: @border-radius;
  2349. border: 0;
  2350. }
  2351. input[type="range"]::-moz-range-thumb {
  2352. box-shadow: 0;
  2353. border: 0;
  2354. height: 19px;
  2355. width: 19px;
  2356. border-radius: 100%;
  2357. background: var(--primary-color);
  2358. cursor: pointer;
  2359. -webkit-appearance: none;
  2360. margin-top: -6.5px;
  2361. }
  2362. input[type="range"]::-ms-track {
  2363. width: 100%;
  2364. height: 5.2px;
  2365. cursor: pointer;
  2366. box-shadow: 0;
  2367. background: var(--light-grey-3);
  2368. border-radius: @border-radius;
  2369. }
  2370. input[type="range"]::-ms-fill-lower {
  2371. background: var(--light-grey-3);
  2372. border: 0;
  2373. border-radius: 0;
  2374. box-shadow: 0;
  2375. }
  2376. input[type="range"]::-ms-fill-upper {
  2377. background: var(--light-grey-3);
  2378. border: 0;
  2379. border-radius: 0;
  2380. box-shadow: 0;
  2381. }
  2382. input[type="range"]::-ms-thumb {
  2383. box-shadow: 0;
  2384. border: 0;
  2385. height: 15px;
  2386. width: 15px;
  2387. border-radius: 100%;
  2388. background: var(--primary-color);
  2389. cursor: pointer;
  2390. -webkit-appearance: none;
  2391. margin-top: 1.5px;
  2392. }
  2393. }
  2394. #right-buttons {
  2395. display: flex;
  2396. #dropdown-toggle {
  2397. width: 35px;
  2398. }
  2399. #dislike-song,
  2400. #add-song-to-playlist .button:not(#dropdown-toggle) {
  2401. margin-left: 5px;
  2402. }
  2403. #ratings {
  2404. display: flex;
  2405. &.liked #dislike-song,
  2406. &.disliked #like-song {
  2407. background-color: var(--grey) !important;
  2408. }
  2409. #like-song.disabled,
  2410. #dislike-song.disabled {
  2411. filter: grayscale(0.4);
  2412. }
  2413. }
  2414. #add-song-to-playlist {
  2415. display: flex;
  2416. flex-direction: column-reverse;
  2417. #nav-dropdown {
  2418. position: absolute;
  2419. margin-left: 4px;
  2420. margin-bottom: 36px;
  2421. .nav-dropdown-items {
  2422. position: relative;
  2423. right: calc(100% - 110px);
  2424. }
  2425. }
  2426. .control {
  2427. width: fit-content;
  2428. margin-bottom: 0 !important;
  2429. button.disabled {
  2430. filter: grayscale(0.4);
  2431. border-radius: @border-radius;
  2432. &::after {
  2433. margin-right: 100%;
  2434. }
  2435. }
  2436. }
  2437. }
  2438. }
  2439. }
  2440. }
  2441. #sidebar-container {
  2442. border-top: 0;
  2443. position: relative;
  2444. height: inherit;
  2445. flex-grow: 1;
  2446. min-height: 350px;
  2447. }
  2448. }
  2449. }
  2450. .footer {
  2451. margin-top: 30px;
  2452. }
  2453. .nyan {
  2454. background: linear-gradient(
  2455. 90deg,
  2456. magenta 0%,
  2457. red 15%,
  2458. orange 30%,
  2459. yellow 45%,
  2460. lime 60%,
  2461. cyan 75%,
  2462. blue 90%,
  2463. magenta 100%
  2464. );
  2465. background-size: 200%;
  2466. animation: nyanMoving 4s linear infinite;
  2467. }
  2468. @keyframes nyanMoving {
  2469. 0% {
  2470. background-position: 0% 0%;
  2471. }
  2472. 100% {
  2473. background-position: -200% 0%;
  2474. }
  2475. }
  2476. .christmas-seeker {
  2477. background: repeating-linear-gradient(
  2478. -45deg,
  2479. var(--white) 0 1rem,
  2480. var(--dark-red) 1rem 2rem
  2481. );
  2482. background-size: 200% 200%;
  2483. animation: christmas 20s linear infinite;
  2484. }
  2485. @keyframes christmas {
  2486. 100% {
  2487. background-position: 80% 100%;
  2488. }
  2489. }
  2490. .bg-bubbles {
  2491. top: 0;
  2492. left: 0;
  2493. width: 100%;
  2494. height: 100%;
  2495. position: absolute;
  2496. z-index: -1;
  2497. margin: 0px;
  2498. pointer-events: none;
  2499. }
  2500. .bg-bubbles li {
  2501. position: absolute;
  2502. list-style: none;
  2503. display: block;
  2504. width: 40px;
  2505. height: 40px;
  2506. border-radius: 100px;
  2507. background-color: var(--primary-color);
  2508. opacity: 0.15;
  2509. bottom: 0px;
  2510. -webkit-animation: square 25s infinite;
  2511. animation: square 25s infinite;
  2512. -webkit-transition-timing-function: linear;
  2513. transition-timing-function: linear;
  2514. }
  2515. .bg-bubbles li:nth-child(1) {
  2516. left: 10%;
  2517. }
  2518. .bg-bubbles li:nth-child(2) {
  2519. left: 20%;
  2520. width: 80px;
  2521. height: 80px;
  2522. -webkit-animation-delay: 2s;
  2523. animation-delay: 2s;
  2524. -webkit-animation-duration: 17s;
  2525. animation-duration: 17s;
  2526. }
  2527. .bg-bubbles li:nth-child(3) {
  2528. left: 25%;
  2529. -webkit-animation-delay: 4s;
  2530. animation-delay: 4s;
  2531. }
  2532. .bg-bubbles li:nth-child(4) {
  2533. left: 40%;
  2534. width: 60px;
  2535. height: 60px;
  2536. -webkit-animation-duration: 22s;
  2537. animation-duration: 22s;
  2538. background-color: var(--primary-color);
  2539. opacity: 0.25;
  2540. }
  2541. .bg-bubbles li:nth-child(5) {
  2542. left: 70%;
  2543. }
  2544. .bg-bubbles li:nth-child(6) {
  2545. left: 80%;
  2546. width: 120px;
  2547. height: 120px;
  2548. -webkit-animation-delay: 3s;
  2549. animation-delay: 3s;
  2550. background-color: var(--primary-color);
  2551. opacity: 0.2;
  2552. }
  2553. .bg-bubbles li:nth-child(7) {
  2554. left: 32%;
  2555. width: 160px;
  2556. height: 160px;
  2557. -webkit-animation-delay: 7s;
  2558. animation-delay: 7s;
  2559. }
  2560. .bg-bubbles li:nth-child(8) {
  2561. left: 55%;
  2562. width: 20px;
  2563. height: 20px;
  2564. -webkit-animation-delay: 15s;
  2565. animation-delay: 15s;
  2566. -webkit-animation-duration: 40s;
  2567. animation-duration: 40s;
  2568. }
  2569. .bg-bubbles li:nth-child(9) {
  2570. left: 25%;
  2571. width: 10px;
  2572. height: 10px;
  2573. -webkit-animation-delay: 2s;
  2574. animation-delay: 2s;
  2575. -webkit-animation-duration: 40s;
  2576. animation-duration: 40s;
  2577. background-color: var(--primary-color);
  2578. opacity: 0.3;
  2579. }
  2580. .bg-bubbles li:nth-child(10) {
  2581. left: 80%;
  2582. width: 160px;
  2583. height: 160px;
  2584. -webkit-animation-delay: 11s;
  2585. animation-delay: 11s;
  2586. }
  2587. /* Tablet view fix */
  2588. @media (max-width: 768px) {
  2589. .bg-bubbles li:nth-child(10) {
  2590. display: none;
  2591. }
  2592. }
  2593. @-webkit-keyframes square {
  2594. 0% {
  2595. -webkit-transform: translateY(0);
  2596. transform: translateY(0);
  2597. }
  2598. 100% {
  2599. -webkit-transform: translateY(-700px) rotate(600deg);
  2600. transform: translateY(-700px) rotate(600deg);
  2601. }
  2602. }
  2603. @keyframes square {
  2604. 0% {
  2605. -webkit-transform: translateY(0);
  2606. transform: translateY(0);
  2607. }
  2608. 100% {
  2609. -webkit-transform: translateY(-700px) rotate(600deg);
  2610. transform: translateY(-700px) rotate(600deg);
  2611. }
  2612. }
  2613. :deep(.nothing-here-text) {
  2614. display: flex;
  2615. align-items: center;
  2616. justify-content: center;
  2617. }
  2618. @media (min-width: 1500px) {
  2619. #station-left-column {
  2620. max-width: 650px;
  2621. }
  2622. #station-right-column {
  2623. max-width: calc(100% - 650px);
  2624. }
  2625. }
  2626. @media (max-width: 1700px) {
  2627. #current-next-row {
  2628. flex-direction: column !important;
  2629. > div {
  2630. flex: 1 !important;
  2631. }
  2632. }
  2633. }
  2634. @media (max-width: 1500px) {
  2635. #mobile-progress-animation {
  2636. display: block;
  2637. }
  2638. #page-loader-container {
  2639. display: none;
  2640. }
  2641. #station-outer-container {
  2642. max-width: 1500px;
  2643. #station-inner-container {
  2644. flex-direction: row;
  2645. #station-left-column {
  2646. #about-station-container #admin-buttons {
  2647. flex-wrap: wrap;
  2648. }
  2649. #sidebar-container {
  2650. min-height: 350px;
  2651. }
  2652. }
  2653. #station-right-column {
  2654. #current-next-row {
  2655. flex-direction: column;
  2656. }
  2657. #control-bar-container {
  2658. #duration,
  2659. #volume-control,
  2660. #right-buttons,
  2661. #left-buttons {
  2662. margin-bottom: 5px;
  2663. justify-content: center;
  2664. }
  2665. #duration {
  2666. order: 1;
  2667. }
  2668. #volume-control {
  2669. order: 2;
  2670. max-width: 400px;
  2671. }
  2672. #right-buttons {
  2673. order: 3;
  2674. flex-wrap: wrap;
  2675. #ratings {
  2676. flex-wrap: wrap;
  2677. }
  2678. }
  2679. #left-buttons {
  2680. order: 4;
  2681. flex-wrap: wrap;
  2682. }
  2683. }
  2684. }
  2685. }
  2686. }
  2687. }
  2688. @media (max-width: 1200px) {
  2689. #station-outer-container {
  2690. max-width: 900px;
  2691. padding: 0;
  2692. #station-inner-container {
  2693. flex-direction: column-reverse;
  2694. flex-wrap: nowrap;
  2695. }
  2696. }
  2697. }
  2698. @media (max-width: 990px) {
  2699. #station-outer-container {
  2700. min-height: calc(
  2701. 100vh - 256px
  2702. ); // Height of nav (64px) + height of footer (190px)
  2703. }
  2704. }
  2705. </style>