index.vue 86 KB

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