index.vue 77 KB

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