index.vue 85 KB

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