index.vue 80 KB

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