index.vue 79 KB

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