index.vue 69 KB

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