index.vue 69 KB

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