index.vue 78 KB

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