index.vue 80 KB

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