index.vue 87 KB

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