index.vue 80 KB

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