index.vue 90 KB

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