index.vue 70 KB

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