index.vue 86 KB

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