index.vue 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950
  1. <template>
  2. <div>
  3. <metadata v-if="exists && !loading" :title="`${station.displayName}`" />
  4. <metadata v-else-if="!exists && !loading" :title="`Not found`" />
  5. <main-header v-if="exists" />
  6. <div id="station-outer-container">
  7. <div v-show="loading" class="progress" />
  8. <div v-show="!loading && exists" id="station-inner-container">
  9. <div id="upper-row" class="row">
  10. <div id="about-station-container" class="quadrant">
  11. <div class="row" id="station-name">
  12. <h1>{{ station.displayName }}</h1>
  13. <a href="#">
  14. <!-- Favourite Station Button -->
  15. <i
  16. v-if="loggedIn && favoriteStation"
  17. @click="unfavoriteStation($event)"
  18. class="material-icons"
  19. >star</i
  20. >
  21. <i
  22. v-if="loggedIn && !favoriteStation"
  23. @click="addfavoriteStation($event)"
  24. class="material-icons"
  25. >star_border</i
  26. >
  27. </a>
  28. </div>
  29. <p>{{ station.description }}</p>
  30. <div id="admin-buttons" v-if="isOwnerOrAdmin()">
  31. <!-- (Admin) Station Settings Button -->
  32. <button
  33. class="button is-primary"
  34. @click="openSettings()"
  35. >
  36. <i class="material-icons icon-with-button"
  37. >settings</i
  38. >
  39. <span class="optional-desktop-only-text">
  40. Station settings
  41. </span>
  42. </button>
  43. <!-- (Admin) Skip Button -->
  44. <button
  45. class="button is-danger"
  46. @click="skipStation()"
  47. >
  48. <i class="material-icons icon-with-button"
  49. >skip_next</i
  50. >
  51. <span class="optional-desktop-only-text">
  52. Force Skip
  53. </span>
  54. </button>
  55. <!-- (Admin) Pause/Resume Button -->
  56. <button
  57. class="button is-danger"
  58. v-if="stationPaused"
  59. @click="resumeStation()"
  60. >
  61. <i class="material-icons icon-with-button"
  62. >play_arrow</i
  63. >
  64. <span class="optional-desktop-only-text">
  65. Resume Station
  66. </span>
  67. </button>
  68. <button
  69. class="button is-danger"
  70. @click="pauseStation()"
  71. v-else
  72. >
  73. <i class="material-icons icon-with-button"
  74. >pause</i
  75. >
  76. <span class="optional-desktop-only-text">
  77. Pause Station
  78. </span>
  79. </button>
  80. </div>
  81. </div>
  82. <div
  83. id="currently-playing-container"
  84. class="quadrant"
  85. :class="{ 'no-currently-playing': noSong }"
  86. >
  87. <currently-playing v-if="!noSong" />
  88. <p v-else class="nothing-here">
  89. No song is currently playing
  90. </p>
  91. </div>
  92. </div>
  93. <div id="lower-row" class="row">
  94. <div class="player-container quadrant" v-show="!noSong">
  95. <div id="video-container">
  96. <div
  97. id="player"
  98. style="width: 100%; height: 100%"
  99. />
  100. <div
  101. class="player-cannot-autoplay"
  102. v-if="!canAutoplay"
  103. >
  104. <p>
  105. Please click anywhere on the screen for the
  106. video to start
  107. </p>
  108. </div>
  109. </div>
  110. <div id="seeker-bar-container">
  111. <div id="seeker-bar" style="width: 0%" />
  112. </div>
  113. <div id="control-bar-container">
  114. <div id="left-buttons">
  115. <!-- Debug Box -->
  116. <button
  117. class="button is-primary"
  118. @click="togglePlayerDebugBox()"
  119. @dblclick="resetPlayerDebugBox()"
  120. >
  121. <i class="material-icons icon-with-button">
  122. bug_report
  123. </i>
  124. <span class="optional-desktop-only-text">
  125. Debug
  126. </span>
  127. </button>
  128. <!-- Local Pause/Resume Button -->
  129. <button
  130. class="button is-primary"
  131. @click="resumeLocalStation()"
  132. id="local-resume"
  133. v-if="localPaused"
  134. >
  135. <i class="material-icons">play_arrow</i>
  136. <span class="optional-desktop-only-text"
  137. >Play locally</span
  138. >
  139. </button>
  140. <button
  141. class="button is-primary"
  142. @click="pauseLocalStation()"
  143. id="local-pause"
  144. v-else
  145. >
  146. <i class="material-icons">pause</i>
  147. <span class="optional-desktop-only-text"
  148. >Pause locally</span
  149. >
  150. </button>
  151. <!-- Vote to Skip Button -->
  152. <button
  153. v-if="loggedIn"
  154. class="button is-primary"
  155. @click="voteSkipStation()"
  156. >
  157. <i class="material-icons icon-with-button"
  158. >skip_next</i
  159. >
  160. <span class="optional-desktop-only-text"
  161. >Vote to skip (</span
  162. >
  163. {{ currentSong.skipVotes }}
  164. <span class="optional-desktop-only-text"
  165. >)</span
  166. >
  167. </button>
  168. </div>
  169. <div id="duration">
  170. <p>
  171. {{ timeElapsed }} /
  172. {{ utils.formatTime(currentSong.duration) }}
  173. </p>
  174. </div>
  175. <p id="volume-control">
  176. <i
  177. v-if="muted"
  178. class="material-icons"
  179. @click="toggleMute()"
  180. >volume_mute</i
  181. >
  182. <i
  183. v-else
  184. class="material-icons"
  185. @click="toggleMute()"
  186. >volume_down</i
  187. >
  188. <input
  189. v-model="volumeSliderValue"
  190. type="range"
  191. min="0"
  192. max="10000"
  193. class="volume-slider active"
  194. @change="changeVolume()"
  195. @input="changeVolume()"
  196. />
  197. <i
  198. class="material-icons"
  199. @click="increaseVolume()"
  200. >volume_up</i
  201. >
  202. </p>
  203. <div id="right-buttons" v-if="loggedIn">
  204. <!-- Ratings (Like/Dislike) Buttons -->
  205. <div
  206. id="ratings"
  207. v-if="
  208. currentSong.likes !== -1 &&
  209. currentSong.dislikes !== -1
  210. "
  211. :class="{
  212. liked: liked,
  213. disliked: disliked
  214. }"
  215. >
  216. <!-- Like Song Button -->
  217. <button
  218. class="button is-success"
  219. id="like-song"
  220. @click="toggleLike()"
  221. >
  222. <i
  223. class="material-icons icon-with-button"
  224. :class="{ liked: liked }"
  225. >thumb_up_alt</i
  226. >{{ currentSong.likes }}
  227. </button>
  228. <!-- Dislike Song Button -->
  229. <button
  230. class="button is-danger"
  231. id="dislike-song"
  232. @click="toggleDislike()"
  233. >
  234. <i
  235. class="material-icons icon-with-button"
  236. :class="{
  237. disliked: disliked
  238. }"
  239. >thumb_down_alt</i
  240. >{{ currentSong.dislikes }}
  241. </button>
  242. </div>
  243. <!-- Add Song To Playlist Button & Dropdown -->
  244. <div id="add-song-to-playlist">
  245. <div class="control has-addons">
  246. <button
  247. class="button is-primary"
  248. @click="
  249. showPlaylistDropdown = !showPlaylistDropdown
  250. "
  251. >
  252. <i class="material-icons">queue</i>
  253. <span
  254. class="optional-desktop-only-text"
  255. >Add Song To Playlist</span
  256. >
  257. </button>
  258. <button
  259. class="button"
  260. id="dropdown-toggle"
  261. @click="
  262. showPlaylistDropdown = !showPlaylistDropdown
  263. "
  264. >
  265. <i class="material-icons">
  266. {{
  267. showPlaylistDropdown
  268. ? "expand_more"
  269. : "expand_less"
  270. }}
  271. </i>
  272. </button>
  273. </div>
  274. <add-to-playlist-dropdown
  275. v-if="showPlaylistDropdown"
  276. />
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <p class="player-container nothing-here" v-if="noSong">
  282. No song is currently playing
  283. </p>
  284. <div id="sidebar-container" class="quadrant">
  285. <station-sidebar />
  286. </div>
  287. </div>
  288. </div>
  289. <song-queue v-if="modals.addSongToQueue" />
  290. <edit-playlist v-if="modals.editPlaylist" />
  291. <create-playlist v-if="modals.createPlaylist" />
  292. <edit-station v-if="modals.editStation" store="station" />
  293. <report v-if="modals.report" />
  294. </div>
  295. <main-footer />
  296. <floating-box id="player-debug-box" ref="playerDebugBox">
  297. <template #body>
  298. <span><b>YouTube id</b>: {{ currentSong.songId }}</span>
  299. <span><b>Duration</b>: {{ currentSong.duration }}</span>
  300. <span
  301. ><b>Skip duration</b>: {{ currentSong.skipDuration }}</span
  302. >
  303. <span><b>Can autoplay</b>: {{ canAutoplay }}</span>
  304. <span
  305. ><b>Attempts to play video</b>:
  306. {{ attemptsToPlayVideo }}</span
  307. >
  308. <span
  309. ><b>Last time requested if can autoplay</b>:
  310. {{ lastTimeRequestedIfCanAutoplay }}</span
  311. >
  312. <span><b>Loading</b>: {{ loading }}</span>
  313. <span><b>Playback rate</b>: {{ playbackRate }}</span>
  314. <span><b>Player ready</b>: {{ playerReady }}</span>
  315. <span><b>Ready</b>: {{ ready }}</span>
  316. <span><b>Seeking</b>: {{ seeking }}</span>
  317. <span><b>System difference</b>: {{ systemDifference }}</span>
  318. <span><b>Time before paused</b>: {{ timeBeforePause }}</span>
  319. <span><b>Time elapsed</b>: {{ timeElapsed }}</span>
  320. <span><b>Time paused</b>: {{ timePaused }}</span>
  321. <span><b>Volume slider value</b>: {{ volumeSliderValue }}</span>
  322. <span><b>Local paused</b>: {{ localPaused }}</span>
  323. <span><b>No song</b>: {{ noSong }}</span>
  324. <span
  325. ><b>Private playlist queue selected</b>:
  326. {{ privatePlaylistQueueSelected }}</span
  327. >
  328. <span><b>Station paused</b>: {{ stationPaused }}</span>
  329. </template>
  330. </floating-box>
  331. <Z404 v-if="!exists"></Z404>
  332. </div>
  333. </template>
  334. <script>
  335. import { mapState, mapActions } from "vuex";
  336. import Toast from "toasters";
  337. import MainHeader from "../../components/layout/MainHeader.vue";
  338. import MainFooter from "../../components/layout/MainFooter.vue";
  339. import Z404 from "../404.vue";
  340. import FloatingBox from "../../components/ui/FloatingBox.vue";
  341. import AddToPlaylistDropdown from "./components/AddToPlaylistDropdown.vue";
  342. import io from "../../io";
  343. import keyboardShortcuts from "../../keyboardShortcuts";
  344. import utils from "../../../js/utils";
  345. import CurrentlyPlaying from "./components/CurrentlyPlaying.vue";
  346. import StationSidebar from "./components/Sidebar/index.vue";
  347. export default {
  348. components: {
  349. MainHeader,
  350. MainFooter,
  351. SongQueue: () => import("./AddSongToQueue.vue"),
  352. EditPlaylist: () => import("../../components/modals/EditPlaylist.vue"),
  353. CreatePlaylist: () =>
  354. import("../../components/modals/CreatePlaylist.vue"),
  355. EditStation: () => import("../../components/modals/EditStation.vue"),
  356. Report: () => import("./Report.vue"),
  357. Z404,
  358. FloatingBox,
  359. CurrentlyPlaying,
  360. StationSidebar,
  361. AddToPlaylistDropdown
  362. },
  363. data() {
  364. return {
  365. utils,
  366. title: "Station",
  367. loading: true,
  368. ready: false,
  369. exists: true,
  370. playerReady: false,
  371. player: undefined,
  372. timePaused: 0,
  373. muted: false,
  374. timeElapsed: "0:00",
  375. liked: false,
  376. disliked: false,
  377. timeBeforePause: 0,
  378. skipVotes: 0,
  379. automaticallyRequestedSongId: null,
  380. systemDifference: 0,
  381. attemptsToPlayVideo: 0,
  382. canAutoplay: true,
  383. lastTimeRequestedIfCanAutoplay: 0,
  384. seeking: false,
  385. playbackRate: 1,
  386. volumeSliderValue: 0,
  387. favoriteStation: false,
  388. showPlaylistDropdown: false
  389. };
  390. },
  391. computed: {
  392. ...mapState("modals", {
  393. modals: state => state.modals.station
  394. }),
  395. ...mapState("station", {
  396. station: state => state.station,
  397. currentSong: state => state.currentSong,
  398. songsList: state => state.songsList,
  399. stationPaused: state => state.stationPaused,
  400. localPaused: state => state.localPaused,
  401. noSong: state => state.noSong,
  402. privatePlaylistQueueSelected: state =>
  403. state.privatePlaylistQueueSelected
  404. }),
  405. ...mapState({
  406. loggedIn: state => state.user.auth.loggedIn,
  407. userId: state => state.user.auth.userId,
  408. role: state => state.user.auth.role
  409. })
  410. },
  411. mounted() {
  412. window.scrollTo(0, 0);
  413. Date.currently = () => {
  414. return new Date().getTime() + this.systemDifference;
  415. };
  416. this.stationName = this.$route.params.id;
  417. window.stationInterval = 0;
  418. io.getSocket(socket => {
  419. this.socket = socket;
  420. io.removeAllListeners();
  421. if (this.socket.connected) this.join();
  422. io.onConnect(this.join);
  423. this.socket.emit("stations.existsByName", this.stationName, res => {
  424. if (res.status === "failure" || !res.exists) {
  425. this.loading = false;
  426. this.exists = false;
  427. }
  428. });
  429. this.socket.on("event:songs.next", data => {
  430. const previousSong = this.currentSong.songId
  431. ? this.currentSong
  432. : null;
  433. this.updatePreviousSong(previousSong);
  434. const { currentSong } = data;
  435. if (currentSong && !currentSong.thumbnail)
  436. currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
  437. this.updateCurrentSong(currentSong || {});
  438. this.startedAt = data.startedAt;
  439. this.updateStationPaused(data.paused);
  440. this.timePaused = data.timePaused;
  441. if (currentSong) {
  442. this.updateNoSong(false);
  443. if (this.currentSong.artists)
  444. this.currentSong.artists = this.currentSong.artists.join(
  445. ", "
  446. );
  447. if (!this.playerReady) this.youtubeReady();
  448. else this.playVideo();
  449. this.socket.emit(
  450. "songs.getOwnSongRatings",
  451. data.currentSong.songId,
  452. song => {
  453. if (this.currentSong.songId === song.songId) {
  454. this.liked = song.liked;
  455. this.disliked = song.disliked;
  456. if (song.disliked === true)
  457. this.voteSkipStation();
  458. }
  459. }
  460. );
  461. } else {
  462. if (this.playerReady) this.player.pauseVideo();
  463. this.updateNoSong(true);
  464. }
  465. let isInQueue = false;
  466. this.songsList.forEach(queueSong => {
  467. if (queueSong.requestedBy === this.userId) isInQueue = true;
  468. });
  469. if (
  470. !isInQueue &&
  471. this.privatePlaylistQueueSelected &&
  472. (this.automaticallyRequestedSongId !==
  473. this.currentSong.songId ||
  474. !this.currentSong.songId)
  475. ) {
  476. this.addFirstPrivatePlaylistSongToQueue();
  477. }
  478. });
  479. this.socket.on("event:stations.pause", data => {
  480. this.pausedAt = data.pausedAt;
  481. this.updateStationPaused(true);
  482. this.pauseLocalPlayer();
  483. });
  484. this.socket.on("event:stations.resume", data => {
  485. this.timePaused = data.timePaused;
  486. this.updateStationPaused(false);
  487. if (!this.localPaused) this.resumeLocalPlayer();
  488. });
  489. this.socket.on("event:stations.remove", () => {
  490. window.location.href = "/";
  491. return true;
  492. });
  493. this.socket.on("event:song.like", data => {
  494. if (!this.noSong) {
  495. if (data.songId === this.currentSong.songId) {
  496. this.currentSong.dislikes = data.dislikes;
  497. this.currentSong.likes = data.likes;
  498. }
  499. }
  500. });
  501. this.socket.on("event:song.dislike", data => {
  502. if (!this.noSong) {
  503. if (data.songId === this.currentSong.songId) {
  504. this.currentSong.dislikes = data.dislikes;
  505. this.currentSong.likes = data.likes;
  506. }
  507. }
  508. });
  509. this.socket.on("event:song.unlike", data => {
  510. if (!this.noSong) {
  511. if (data.songId === this.currentSong.songId) {
  512. this.currentSong.dislikes = data.dislikes;
  513. this.currentSong.likes = data.likes;
  514. }
  515. }
  516. });
  517. this.socket.on("event:song.undislike", data => {
  518. if (!this.noSong) {
  519. if (data.songId === this.currentSong.songId) {
  520. this.currentSong.dislikes = data.dislikes;
  521. this.currentSong.likes = data.likes;
  522. }
  523. }
  524. });
  525. this.socket.on("event:song.newRatings", data => {
  526. if (!this.noSong) {
  527. if (data.songId === this.currentSong.songId) {
  528. this.liked = data.liked;
  529. this.disliked = data.disliked;
  530. }
  531. }
  532. });
  533. this.socket.on("event:queue.update", queue => {
  534. if (this.station.type === "community")
  535. this.updateSongsList(queue);
  536. });
  537. this.socket.on("event:song.voteSkipSong", () => {
  538. if (this.currentSong) this.currentSong.skipVotes += 1;
  539. });
  540. this.socket.on("event:privatePlaylist.selected", playlistId => {
  541. if (this.station.type === "community") {
  542. this.station.privatePlaylist = playlistId;
  543. }
  544. });
  545. this.socket.on("event:partyMode.updated", partyMode => {
  546. if (this.station.type === "community") {
  547. this.station.partyMode = partyMode;
  548. }
  549. });
  550. this.socket.on("event:newOfficialPlaylist", playlist => {
  551. if (this.station.type === "official") {
  552. this.updateSongsList(playlist);
  553. }
  554. });
  555. this.socket.on("event:users.updated", users => {
  556. this.updateUsers(users);
  557. });
  558. this.socket.on("event:userCount.updated", userCount => {
  559. this.updateUserCount(userCount);
  560. });
  561. this.socket.on("event:queueLockToggled", locked => {
  562. this.station.locked = locked;
  563. });
  564. this.socket.on("event:user.favoritedStation", stationId => {
  565. if (stationId === this.station._id) this.favoriteStation = true;
  566. });
  567. this.socket.on("event:user.unfavoritedStation", stationId => {
  568. if (stationId === this.station._id)
  569. this.favoriteStation = false;
  570. });
  571. });
  572. if (JSON.parse(localStorage.getItem("muted"))) {
  573. this.muted = true;
  574. this.player.setVolume(0);
  575. this.volumeSliderValue = 0 * 100;
  576. } else {
  577. let volume = parseFloat(localStorage.getItem("volume"));
  578. volume =
  579. typeof volume === "number" && !Number.isNaN(volume)
  580. ? volume
  581. : 20;
  582. localStorage.setItem("volume", volume);
  583. this.volumeSliderValue = volume * 100;
  584. }
  585. },
  586. beforeDestroy() {
  587. /** Reset Songslist */
  588. this.updateSongsList([]);
  589. const shortcutNames = [
  590. "station.pauseResume",
  591. "station.skipStation",
  592. "station.lowerVolumeLarge",
  593. "station.lowerVolumeSmall",
  594. "station.increaseVolumeLarge",
  595. "station.increaseVolumeSmall",
  596. "station.toggleDebug"
  597. ];
  598. shortcutNames.forEach(shortcutName => {
  599. keyboardShortcuts.unregisterShortcut(shortcutName);
  600. });
  601. },
  602. methods: {
  603. isOwnerOnly() {
  604. return this.loggedIn && this.userId === this.station.owner;
  605. },
  606. isAdminOnly() {
  607. return this.loggedIn && this.role === "admin";
  608. },
  609. isOwnerOrAdmin() {
  610. return this.isOwnerOnly() || this.isAdminOnly();
  611. },
  612. openSettings() {
  613. this.editStation({
  614. _id: this.station._id,
  615. name: this.station.name,
  616. type: this.station.type,
  617. partyMode: this.station.partyMode,
  618. description: this.station.description,
  619. privacy: this.station.privacy,
  620. displayName: this.station.displayName,
  621. locked: this.station.locked,
  622. genres: this.station.genres,
  623. blacklistedGenres: this.station.blacklistedGenres
  624. });
  625. this.openModal({
  626. sector: "station",
  627. modal: "editStation"
  628. });
  629. },
  630. removeFromQueue(songId) {
  631. window.socket.emit(
  632. "stations.removeFromQueue",
  633. this.station._id,
  634. songId,
  635. res => {
  636. if (res.status === "success") {
  637. new Toast({
  638. content:
  639. "Successfully removed song from the queue.",
  640. timeout: 4000
  641. });
  642. } else new Toast({ content: res.message, timeout: 8000 });
  643. }
  644. );
  645. },
  646. youtubeReady() {
  647. if (!this.player) {
  648. this.player = new window.YT.Player("player", {
  649. height: 270,
  650. width: 480,
  651. videoId: this.currentSong.songId,
  652. host: "https://www.youtube-nocookie.com",
  653. startSeconds:
  654. this.getTimeElapsed() / 1000 +
  655. this.currentSong.skipDuration,
  656. playerVars: {
  657. controls: 0,
  658. iv_load_policy: 3,
  659. rel: 0,
  660. showinfo: 0
  661. },
  662. events: {
  663. onReady: () => {
  664. this.playerReady = true;
  665. let volume = parseInt(
  666. localStorage.getItem("volume")
  667. );
  668. volume = typeof volume === "number" ? volume : 20;
  669. this.player.setVolume(volume);
  670. if (volume > 0) {
  671. this.player.unMute();
  672. }
  673. if (this.muted) this.player.mute();
  674. this.playVideo();
  675. },
  676. onError: err => {
  677. console.log("iframe error", err);
  678. if (this.loggedIn) this.voteSkipStation();
  679. },
  680. onStateChange: event => {
  681. if (
  682. event.data === window.YT.PlayerState.PLAYING &&
  683. this.videoLoading === true
  684. ) {
  685. this.videoLoading = false;
  686. this.player.seekTo(
  687. this.getTimeElapsed() / 1000 +
  688. this.currentSong.skipDuration,
  689. true
  690. );
  691. if (this.localPaused || this.stationPaused)
  692. this.player.pauseVideo();
  693. } else if (
  694. event.data === window.YT.PlayerState.PLAYING &&
  695. (this.localPaused || this.stationPaused)
  696. ) {
  697. this.player.seekTo(
  698. this.timeBeforePause / 1000,
  699. true
  700. );
  701. this.player.pauseVideo();
  702. } else if (
  703. event.data === window.YT.PlayerState.PLAYING &&
  704. this.seeking === true
  705. ) {
  706. this.seeking = false;
  707. }
  708. if (
  709. event.data === window.YT.PlayerState.PAUSED &&
  710. !this.localPaused &&
  711. !this.stationPaused &&
  712. !this.noSong &&
  713. this.player.getDuration() / 1000 <
  714. this.currentSong.duration
  715. ) {
  716. this.player.seekTo(
  717. this.getTimeElapsed() / 1000 +
  718. this.currentSong.skipDuration,
  719. true
  720. );
  721. this.player.playVideo();
  722. }
  723. }
  724. }
  725. });
  726. }
  727. },
  728. getTimeElapsed() {
  729. if (this.currentSong) {
  730. let { timePaused } = this;
  731. if (this.stationPaused)
  732. timePaused += Date.currently() - this.pausedAt;
  733. return Date.currently() - this.startedAt - timePaused;
  734. }
  735. return 0;
  736. },
  737. playVideo() {
  738. if (this.playerReady) {
  739. this.videoLoading = true;
  740. this.player.loadVideoById(
  741. this.currentSong.songId,
  742. this.getTimeElapsed() / 1000 + this.currentSong.skipDuration
  743. );
  744. if (window.stationInterval !== 0)
  745. clearInterval(window.stationInterval);
  746. window.stationInterval = setInterval(() => {
  747. this.resizeSeekerbar();
  748. this.calculateTimeElapsed();
  749. }, 150);
  750. }
  751. },
  752. resizeSeekerbar() {
  753. if (!this.stationPaused) {
  754. document.getElementById(
  755. "seeker-bar"
  756. ).style.width = `${parseFloat(
  757. (this.getTimeElapsed() / 1000 / this.currentSong.duration) *
  758. 100
  759. )}%`;
  760. }
  761. },
  762. calculateTimeElapsed() {
  763. if (
  764. this.playerReady &&
  765. this.currentSong &&
  766. this.player.getPlayerState() === -1
  767. ) {
  768. if (this.attemptsToPlayVideo >= 5) {
  769. if (
  770. Date.now() - this.lastTimeRequestedIfCanAutoplay >
  771. 2000
  772. ) {
  773. this.lastTimeRequestedIfCanAutoplay = Date.now();
  774. window.canAutoplay.video().then(({ result }) => {
  775. if (result) {
  776. this.attemptsToPlayVideo = 0;
  777. this.canAutoplay = true;
  778. } else {
  779. this.canAutoplay = false;
  780. }
  781. });
  782. }
  783. } else {
  784. this.player.playVideo();
  785. this.attemptsToPlayVideo += 1;
  786. }
  787. }
  788. if (!this.stationPaused && !this.localPaused) {
  789. const timeElapsed = this.getTimeElapsed();
  790. const currentPlayerTime =
  791. Math.max(
  792. this.player.getCurrentTime() -
  793. this.currentSong.skipDuration,
  794. 0
  795. ) * 1000;
  796. const difference = timeElapsed - currentPlayerTime;
  797. // console.log(difference);
  798. let playbackRate = 1;
  799. if (difference < -2000) {
  800. if (!this.seeking) {
  801. this.seeking = true;
  802. this.player.seekTo(
  803. this.getTimeElapsed() / 1000 +
  804. this.currentSong.skipDuration
  805. );
  806. }
  807. } else if (difference < -200) {
  808. // console.log("Difference0.8");
  809. playbackRate = 0.8;
  810. } else if (difference < -50) {
  811. // console.log("Difference0.9");
  812. playbackRate = 0.9;
  813. } else if (difference < -25) {
  814. // console.log("Difference0.99");
  815. playbackRate = 0.95;
  816. } else if (difference > 2000) {
  817. if (!this.seeking) {
  818. this.seeking = true;
  819. this.player.seekTo(
  820. this.getTimeElapsed() / 1000 +
  821. this.currentSong.skipDuration
  822. );
  823. }
  824. } else if (difference > 200) {
  825. // console.log("Difference1.2");
  826. playbackRate = 1.2;
  827. } else if (difference > 50) {
  828. // console.log("Difference1.1");
  829. playbackRate = 1.1;
  830. } else if (difference > 25) {
  831. // console.log("Difference1.01");
  832. playbackRate = 1.05;
  833. } else if (this.player.getPlaybackRate !== 1.0) {
  834. // console.log("NDifference1.0");
  835. this.player.setPlaybackRate(1.0);
  836. }
  837. if (this.playbackRate !== playbackRate) {
  838. this.player.setPlaybackRate(playbackRate);
  839. this.playbackRate = playbackRate;
  840. }
  841. }
  842. /* if (this.currentTime !== undefined && this.paused) {
  843. this.timePaused += Date.currently() - this.currentTime;
  844. this.currentTime = undefined;
  845. } */
  846. let { timePaused } = this;
  847. if (this.stationPaused)
  848. timePaused += Date.currently() - this.pausedAt;
  849. const duration =
  850. (Date.currently() - this.startedAt - timePaused) / 1000;
  851. const songDuration = this.currentSong.duration;
  852. if (songDuration <= duration) this.player.pauseVideo();
  853. if (!this.stationPaused && duration <= songDuration)
  854. this.timeElapsed = utils.formatTime(duration);
  855. },
  856. toggleLock() {
  857. window.socket.emit("stations.toggleLock", this.station._id, res => {
  858. if (res.status === "success") {
  859. new Toast({
  860. content: "Successfully toggled the queue lock.",
  861. timeout: 4000
  862. });
  863. } else new Toast({ content: res.message, timeout: 8000 });
  864. });
  865. },
  866. changeVolume() {
  867. const volume = this.volumeSliderValue;
  868. localStorage.setItem("volume", volume / 100);
  869. if (this.playerReady) {
  870. this.player.setVolume(volume / 100);
  871. if (volume > 0) {
  872. this.player.unMute();
  873. localStorage.setItem("muted", false);
  874. this.muted = false;
  875. }
  876. }
  877. },
  878. resumeLocalStation() {
  879. this.updateLocalPaused(false);
  880. if (!this.stationPaused) this.resumeLocalPlayer();
  881. },
  882. pauseLocalStation() {
  883. this.updateLocalPaused(true);
  884. this.pauseLocalPlayer();
  885. },
  886. resumeLocalPlayer() {
  887. if (!this.noSong) {
  888. if (this.playerReady) {
  889. this.player.seekTo(
  890. this.getTimeElapsed() / 1000 +
  891. this.currentSong.skipDuration
  892. );
  893. this.player.playVideo();
  894. }
  895. }
  896. },
  897. pauseLocalPlayer() {
  898. if (!this.noSong) {
  899. this.timeBeforePause = this.getTimeElapsed();
  900. if (this.playerReady) this.player.pauseVideo();
  901. }
  902. },
  903. skipStation() {
  904. this.socket.emit("stations.forceSkip", this.station._id, data => {
  905. if (data.status !== "success")
  906. new Toast({
  907. content: `Error: ${data.message}`,
  908. timeout: 8000
  909. });
  910. else
  911. new Toast({
  912. content:
  913. "Successfully skipped the station's current song.",
  914. timeout: 4000
  915. });
  916. });
  917. },
  918. voteSkipStation() {
  919. this.socket.emit("stations.voteSkip", this.station._id, data => {
  920. if (data.status !== "success")
  921. new Toast({
  922. content: `Error: ${data.message}`,
  923. timeout: 8000
  924. });
  925. else
  926. new Toast({
  927. content: "Successfully voted to skip the current song.",
  928. timeout: 4000
  929. });
  930. });
  931. },
  932. resumeStation() {
  933. this.socket.emit("stations.resume", this.station._id, data => {
  934. if (data.status !== "success")
  935. new Toast({
  936. content: `Error: ${data.message}`,
  937. timeout: 8000
  938. });
  939. else
  940. new Toast({
  941. content: "Successfully resumed the station.",
  942. timeout: 4000
  943. });
  944. });
  945. },
  946. pauseStation() {
  947. this.socket.emit("stations.pause", this.station._id, data => {
  948. if (data.status !== "success")
  949. new Toast({
  950. content: `Error: ${data.message}`,
  951. timeout: 8000
  952. });
  953. else
  954. new Toast({
  955. content: "Successfully paused the station.",
  956. timeout: 4000
  957. });
  958. });
  959. },
  960. toggleMute() {
  961. if (this.playerReady) {
  962. const previousVolume = parseFloat(
  963. localStorage.getItem("volume")
  964. );
  965. const volume =
  966. this.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  967. this.muted = !this.muted;
  968. localStorage.setItem("muted", this.muted);
  969. this.volumeSliderValue = volume * 100;
  970. this.player.setVolume(volume);
  971. if (!this.muted) localStorage.setItem("volume", volume);
  972. }
  973. },
  974. increaseVolume() {
  975. if (this.playerReady) {
  976. const previousVolume = parseInt(localStorage.getItem("volume"));
  977. let volume = previousVolume + 5;
  978. if (previousVolume === 0) {
  979. this.muted = false;
  980. localStorage.setItem("muted", false);
  981. }
  982. if (volume > 100) volume = 100;
  983. this.volumeSliderValue = volume * 100;
  984. this.player.setVolume(volume);
  985. localStorage.setItem("volume", volume);
  986. }
  987. },
  988. toggleLike() {
  989. if (this.liked)
  990. this.socket.emit(
  991. "songs.unlike",
  992. this.currentSong.songId,
  993. data => {
  994. if (data.status !== "success")
  995. new Toast({
  996. content: `Error: ${data.message}`,
  997. timeout: 8000
  998. });
  999. }
  1000. );
  1001. else
  1002. this.socket.emit(
  1003. "songs.like",
  1004. this.currentSong.songId,
  1005. data => {
  1006. if (data.status !== "success")
  1007. new Toast({
  1008. content: `Error: ${data.message}`,
  1009. timeout: 8000
  1010. });
  1011. }
  1012. );
  1013. },
  1014. toggleDislike() {
  1015. if (this.disliked)
  1016. return this.socket.emit(
  1017. "songs.undislike",
  1018. this.currentSong.songId,
  1019. data => {
  1020. if (data.status !== "success")
  1021. new Toast({
  1022. content: `Error: ${data.message}`,
  1023. timeout: 8000
  1024. });
  1025. }
  1026. );
  1027. return this.socket.emit(
  1028. "songs.dislike",
  1029. this.currentSong.songId,
  1030. data => {
  1031. if (data.status !== "success")
  1032. new Toast({
  1033. content: `Error: ${data.message}`,
  1034. timeout: 8000
  1035. });
  1036. }
  1037. );
  1038. },
  1039. addFirstPrivatePlaylistSongToQueue() {
  1040. let isInQueue = false;
  1041. if (
  1042. this.station.type === "community" &&
  1043. this.station.partyMode === true
  1044. ) {
  1045. this.songsList.forEach(queueSong => {
  1046. if (queueSong.requestedBy === this.userId) isInQueue = true;
  1047. });
  1048. if (!isInQueue && this.privatePlaylistQueueSelected) {
  1049. this.socket.emit(
  1050. "playlists.getFirstSong",
  1051. this.privatePlaylistQueueSelected,
  1052. data => {
  1053. if (data.status === "success") {
  1054. if (data.song) {
  1055. if (data.song.duration < 15 * 60) {
  1056. this.automaticallyRequestedSongId =
  1057. data.song.songId;
  1058. this.socket.emit(
  1059. "stations.addToQueue",
  1060. this.station._id,
  1061. data.song.songId,
  1062. data2 => {
  1063. if (
  1064. data2.status === "success"
  1065. ) {
  1066. this.socket.emit(
  1067. "playlists.moveSongToBottom",
  1068. this
  1069. .privatePlaylistQueueSelected,
  1070. data.song.songId,
  1071. data3 => {
  1072. if (
  1073. data3.status ===
  1074. "success"
  1075. ) {
  1076. console.log(
  1077. "This comment is just here because of eslint/prettier issues, ignore it"
  1078. );
  1079. }
  1080. }
  1081. );
  1082. }
  1083. }
  1084. );
  1085. } else {
  1086. new Toast({
  1087. content: `Top song in playlist was too long to be added.`,
  1088. timeout: 3000
  1089. });
  1090. this.socket.emit(
  1091. "playlists.moveSongToBottom",
  1092. this.privatePlaylistQueueSelected,
  1093. data.song.songId,
  1094. data3 => {
  1095. if (
  1096. data3.status === "success"
  1097. ) {
  1098. setTimeout(() => {
  1099. this.addFirstPrivatePlaylistSongToQueue();
  1100. }, 3000);
  1101. }
  1102. }
  1103. );
  1104. }
  1105. } else {
  1106. new Toast({
  1107. content: `Selected playlist has no songs.`,
  1108. timeout: 4000
  1109. });
  1110. }
  1111. }
  1112. }
  1113. );
  1114. }
  1115. }
  1116. },
  1117. togglePlayerDebugBox() {
  1118. this.$refs.playerDebugBox.toggleBox();
  1119. },
  1120. resetPlayerDebugBox() {
  1121. this.$refs.playerDebugBox.resetBox();
  1122. },
  1123. join() {
  1124. this.socket.emit("stations.join", this.stationName, res => {
  1125. if (res.status === "success") {
  1126. this.loading = false;
  1127. const {
  1128. _id,
  1129. displayName,
  1130. description,
  1131. privacy,
  1132. locked,
  1133. partyMode,
  1134. owner,
  1135. privatePlaylist,
  1136. type,
  1137. genres,
  1138. blacklistedGenres
  1139. } = res.data;
  1140. this.joinStation({
  1141. _id,
  1142. name: this.stationName,
  1143. displayName,
  1144. description,
  1145. privacy,
  1146. locked,
  1147. partyMode,
  1148. owner,
  1149. privatePlaylist,
  1150. type,
  1151. genres,
  1152. blacklistedGenres
  1153. });
  1154. const currentSong = res.data.currentSong
  1155. ? res.data.currentSong
  1156. : {};
  1157. if (currentSong.artists)
  1158. currentSong.artists = currentSong.artists.join(", ");
  1159. if (currentSong && !currentSong.thumbnail)
  1160. currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
  1161. this.updateCurrentSong(currentSong);
  1162. this.startedAt = res.data.startedAt;
  1163. this.updateStationPaused(res.data.paused);
  1164. this.timePaused = res.data.timePaused;
  1165. this.updateUserCount(res.data.userCount);
  1166. this.updateUsers(res.data.users);
  1167. this.pausedAt = res.data.pausedAt;
  1168. if (res.data.currentSong) {
  1169. this.updateNoSong(false);
  1170. this.youtubeReady();
  1171. this.playVideo();
  1172. this.socket.emit(
  1173. "songs.getOwnSongRatings",
  1174. res.data.currentSong.songId,
  1175. data => {
  1176. if (this.currentSong.songId === data.songId) {
  1177. this.liked = data.liked;
  1178. this.disliked = data.disliked;
  1179. }
  1180. }
  1181. );
  1182. } else {
  1183. if (this.playerReady) this.player.pauseVideo();
  1184. this.updateNoSong(true);
  1185. }
  1186. if (type === "community" && partyMode === true) {
  1187. this.socket.emit("stations.getQueue", _id, res => {
  1188. if (res.status === "success") {
  1189. this.updateSongsList(res.queue);
  1190. }
  1191. });
  1192. }
  1193. if (this.isOwnerOrAdmin()) {
  1194. keyboardShortcuts.registerShortcut(
  1195. "station.pauseResume",
  1196. {
  1197. keyCode: 32,
  1198. shift: false,
  1199. ctrl: true,
  1200. preventDefault: true,
  1201. handler: () => {
  1202. if (this.stationPaused)
  1203. this.resumeStation();
  1204. else this.pauseStation();
  1205. }
  1206. }
  1207. );
  1208. keyboardShortcuts.registerShortcut(
  1209. "station.skipStation",
  1210. {
  1211. keyCode: 39,
  1212. shift: false,
  1213. ctrl: true,
  1214. preventDefault: true,
  1215. handler: () => {
  1216. this.skipStation();
  1217. }
  1218. }
  1219. );
  1220. }
  1221. keyboardShortcuts.registerShortcut(
  1222. "station.lowerVolumeLarge",
  1223. {
  1224. keyCode: 40,
  1225. shift: false,
  1226. ctrl: true,
  1227. preventDefault: true,
  1228. handler: () => {
  1229. this.volumeSliderValue -= 1000;
  1230. this.changeVolume();
  1231. }
  1232. }
  1233. );
  1234. keyboardShortcuts.registerShortcut(
  1235. "station.lowerVolumeSmall",
  1236. {
  1237. keyCode: 40,
  1238. shift: true,
  1239. ctrl: true,
  1240. preventDefault: true,
  1241. handler: () => {
  1242. this.volumeSliderValue -= 100;
  1243. this.changeVolume();
  1244. }
  1245. }
  1246. );
  1247. keyboardShortcuts.registerShortcut(
  1248. "station.increaseVolumeLarge",
  1249. {
  1250. keyCode: 38,
  1251. shift: false,
  1252. ctrl: true,
  1253. preventDefault: true,
  1254. handler: () => {
  1255. this.volumeSliderValue += 1000;
  1256. this.changeVolume();
  1257. }
  1258. }
  1259. );
  1260. keyboardShortcuts.registerShortcut(
  1261. "station.increaseVolumeSmall",
  1262. {
  1263. keyCode: 38,
  1264. shift: true,
  1265. ctrl: true,
  1266. preventDefault: true,
  1267. handler: () => {
  1268. this.volumeSliderValue += 100;
  1269. this.changeVolume();
  1270. }
  1271. }
  1272. );
  1273. keyboardShortcuts.registerShortcut("station.toggleDebug", {
  1274. keyCode: 68,
  1275. shift: false,
  1276. ctrl: true,
  1277. preventDefault: true,
  1278. handler: () => {
  1279. this.togglePlayerDebugBox();
  1280. }
  1281. });
  1282. // UNIX client time before ping
  1283. const beforePing = Date.now();
  1284. this.socket.emit("apis.ping", pong => {
  1285. // UNIX client time after ping
  1286. const afterPing = Date.now();
  1287. // Average time in MS it took between the server responding and the client receiving
  1288. const connectionLatency = (afterPing - beforePing) / 2;
  1289. console.log(connectionLatency, beforePing - afterPing);
  1290. // UNIX server time
  1291. const serverDate = pong.date;
  1292. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  1293. const difference =
  1294. serverDate + connectionLatency - afterPing;
  1295. console.log("Difference: ", difference);
  1296. if (difference > 3000 || difference < -3000) {
  1297. console.log(
  1298. "System time difference is bigger than 3 seconds."
  1299. );
  1300. }
  1301. this.systemDifference = difference;
  1302. });
  1303. } else {
  1304. this.loading = false;
  1305. this.exists = false;
  1306. }
  1307. });
  1308. this.socket.emit("users.getFavoriteStations", data => {
  1309. if (
  1310. data.status === "success" &&
  1311. data.favoriteStations.indexOf(this.station._id) !== -1
  1312. )
  1313. this.favoriteStation = true;
  1314. });
  1315. },
  1316. addfavoriteStation(event) {
  1317. event.preventDefault();
  1318. this.socket.emit(
  1319. "stations.favoriteStation",
  1320. this.station._id,
  1321. res => {
  1322. if (res.status === "success") {
  1323. new Toast({
  1324. content: "Successfully favorited station.",
  1325. timeout: 4000
  1326. });
  1327. } else new Toast({ content: res.message, timeout: 8000 });
  1328. }
  1329. );
  1330. },
  1331. unfavoriteStation(event) {
  1332. event.preventDefault();
  1333. this.socket.emit(
  1334. "stations.unfavoriteStation",
  1335. this.station._id,
  1336. res => {
  1337. if (res.status === "success") {
  1338. new Toast({
  1339. content: "Successfully unfavorited station.",
  1340. timeout: 4000
  1341. });
  1342. } else new Toast({ content: res.message, timeout: 8000 });
  1343. }
  1344. );
  1345. },
  1346. ...mapActions("modals", ["openModal"]),
  1347. ...mapActions("station", [
  1348. "joinStation",
  1349. "updateUserCount",
  1350. "updateUsers",
  1351. "updateCurrentSong",
  1352. "updatePreviousSong",
  1353. "updateSongsList",
  1354. "updateStationPaused",
  1355. "updateLocalPaused",
  1356. "updateNoSong",
  1357. "editStation"
  1358. ])
  1359. }
  1360. };
  1361. </script>
  1362. <style lang="scss" scoped>
  1363. @import "../../styles/global.scss";
  1364. .main-container {
  1365. min-height: calc(100vh + 100px);
  1366. }
  1367. .progress {
  1368. width: 50px;
  1369. animation: rotate 0.8s infinite linear;
  1370. border: 8px solid $primary-color;
  1371. border-right-color: transparent;
  1372. height: 50px;
  1373. position: absolute;
  1374. top: 50%;
  1375. left: 50%;
  1376. }
  1377. @keyframes rotate {
  1378. 0% {
  1379. transform: rotate(0deg);
  1380. }
  1381. 100% {
  1382. transform: rotate(360deg);
  1383. }
  1384. }
  1385. .experimental {
  1386. display: none !important;
  1387. }
  1388. #player-debug-box {
  1389. .box-body {
  1390. flex-direction: column;
  1391. b {
  1392. color: #000;
  1393. }
  1394. }
  1395. }
  1396. .night-mode {
  1397. #currently-playing-container,
  1398. #about-station-container,
  1399. #control-bar-container,
  1400. .player-container.nothing-here {
  1401. background-color: $night-mode-bg-secondary !important;
  1402. }
  1403. #upper-row .quadrant,
  1404. #video-container,
  1405. #control-bar-container {
  1406. border: 0 !important;
  1407. }
  1408. #dropdown-toggle {
  1409. background-color: $dark-grey !important;
  1410. border: 0;
  1411. i {
  1412. color: #fff;
  1413. }
  1414. }
  1415. }
  1416. #station-outer-container {
  1417. margin: 0 auto;
  1418. max-width: 100%;
  1419. padding: 20px 40px;
  1420. margin-top: 5px;
  1421. height: 100%;
  1422. /** Mobile Row */
  1423. @media (max-width: 1040px) {
  1424. padding: 0;
  1425. margin-top: 0 !important;
  1426. height: auto !important;
  1427. #station-inner-container {
  1428. justify-content: flex-start !important;
  1429. }
  1430. .row {
  1431. width: 100%;
  1432. flex-direction: column !important;
  1433. }
  1434. .quadrant,
  1435. .player-container {
  1436. width: 100% !important;
  1437. border: 0 !important;
  1438. }
  1439. .quadrant,
  1440. .player-container {
  1441. background: transparent !important;
  1442. }
  1443. /** padding fixes on mobile */
  1444. #about-station-container,
  1445. #currently-playing-container {
  1446. padding: 15px 10px !important;
  1447. }
  1448. #about-station-container:not(.nothing-here) {
  1449. padding-bottom: 0 !important;
  1450. }
  1451. #currently-playing {
  1452. padding: 0;
  1453. }
  1454. /** no column gap between quadrants on mobile */
  1455. #currently-playing-container,
  1456. #sidebar-container {
  1457. margin-left: 0 !important;
  1458. }
  1459. #lower-row {
  1460. margin-top: 0 !important;
  1461. }
  1462. /** Change height of YouTube embed */
  1463. .player-container:not(.nothing-here) {
  1464. height: 800px !important;
  1465. }
  1466. .player-container {
  1467. height: 50px;
  1468. }
  1469. /** mainly irrelevant on mobile */
  1470. .no-currently-playing {
  1471. display: none !important;
  1472. }
  1473. }
  1474. #station-inner-container {
  1475. display: flex;
  1476. align-items: center;
  1477. flex-direction: column;
  1478. height: 100%;
  1479. @media (min-height: 1050px) {
  1480. justify-content: center;
  1481. }
  1482. @media (min-width: 1040px) and (max-width: 2100px) {
  1483. #control-bar-container {
  1484. .optional-desktop-only-text {
  1485. display: none;
  1486. }
  1487. .button:not(#dropdown-toggle) {
  1488. width: 75px;
  1489. }
  1490. #add-song-to-playlist .button,
  1491. #local-resume,
  1492. #local-pause {
  1493. i {
  1494. margin-right: 0 !important;
  1495. }
  1496. }
  1497. }
  1498. }
  1499. .row {
  1500. display: flex;
  1501. flex-direction: row;
  1502. max-width: 100%;
  1503. .quadrant {
  1504. display: flex;
  1505. align-items: center;
  1506. justify-content: center;
  1507. flex-direction: column;
  1508. max-width: 100%;
  1509. border-radius: 5px;
  1510. }
  1511. }
  1512. #upper-row {
  1513. .quadrant {
  1514. border: 1px solid $light-grey-2;
  1515. background-color: #fff;
  1516. }
  1517. #about-station-container {
  1518. width: 1400px;
  1519. align-items: flex-start;
  1520. padding: 20px;
  1521. #station-name {
  1522. flex-direction: row !important;
  1523. h1 {
  1524. margin: 0;
  1525. font-size: 36px;
  1526. }
  1527. i {
  1528. margin-left: 10px;
  1529. font-size: 30px;
  1530. color: $yellow;
  1531. }
  1532. }
  1533. p {
  1534. max-width: 700px;
  1535. flex-grow: 1;
  1536. }
  1537. #admin-buttons {
  1538. margin-top: 15px;
  1539. @media (max-width: 450px) {
  1540. .optional-desktop-only-text {
  1541. display: none;
  1542. }
  1543. }
  1544. }
  1545. }
  1546. #currently-playing-container {
  1547. width: 550px;
  1548. margin-left: 50px;
  1549. }
  1550. }
  1551. #lower-row {
  1552. margin-top: 20px;
  1553. height: calc(100% - 75px); // accounts for footer
  1554. .player-container.nothing-here {
  1555. border: 1px solid $light-grey-2;
  1556. border-radius: 5px;
  1557. }
  1558. .player-container {
  1559. height: inherit;
  1560. width: 1400px;
  1561. background-color: #fff;
  1562. display: flex;
  1563. flex-direction: column;
  1564. border: 1px solid $light-grey-2;
  1565. border-radius: 5px;
  1566. overflow: hidden;
  1567. #video-container {
  1568. width: 100%;
  1569. height: 100%;
  1570. .player-cannot-autoplay {
  1571. position: relative;
  1572. width: 100%;
  1573. height: 100%;
  1574. bottom: calc(100% + 5px);
  1575. background: rgba(3, 169, 244, 0.95);
  1576. display: flex;
  1577. align-items: center;
  1578. justify-content: center;
  1579. p {
  1580. color: $white;
  1581. font-size: 26px;
  1582. text-align: center;
  1583. }
  1584. }
  1585. }
  1586. #seeker-bar-container {
  1587. background-color: #fff;
  1588. position: relative;
  1589. height: 7px;
  1590. display: block;
  1591. width: 100%;
  1592. overflow: hidden;
  1593. #seeker-bar {
  1594. background-color: $musare-blue;
  1595. top: 0;
  1596. left: 0;
  1597. bottom: 0;
  1598. position: absolute;
  1599. }
  1600. }
  1601. #control-bar-container {
  1602. display: flex;
  1603. justify-content: space-around;
  1604. padding: 10px 0;
  1605. width: 100%;
  1606. background: #fff;
  1607. flex-direction: column;
  1608. flex-flow: wrap;
  1609. #left-buttons,
  1610. #right-buttons {
  1611. margin: 3px;
  1612. i {
  1613. margin-right: 3px;
  1614. }
  1615. }
  1616. #left-buttons {
  1617. display: flex;
  1618. .button:not(:first-of-type) {
  1619. margin-left: 5px;
  1620. }
  1621. }
  1622. #duration {
  1623. margin: 3px;
  1624. display: flex;
  1625. align-items: center;
  1626. p {
  1627. font-size: 22px;
  1628. /** prevents duration width slightly varying and shifting other controls slightly */
  1629. width: 125px;
  1630. text-align: center;
  1631. }
  1632. }
  1633. #volume-control {
  1634. margin: 3px;
  1635. margin-top: 0;
  1636. position: relative;
  1637. display: flex;
  1638. align-items: center;
  1639. cursor: pointer;
  1640. .volume-slider {
  1641. width: 500px;
  1642. padding: 0 15px;
  1643. background: transparent;
  1644. @media (max-width: 2150px) {
  1645. width: 250px !important;
  1646. }
  1647. }
  1648. input[type="range"] {
  1649. -webkit-appearance: none;
  1650. margin: 7.3px 0;
  1651. }
  1652. input[type="range"]:focus {
  1653. outline: none;
  1654. }
  1655. input[type="range"]::-webkit-slider-runnable-track {
  1656. width: 100%;
  1657. height: 5.2px;
  1658. cursor: pointer;
  1659. box-shadow: 0;
  1660. background: $light-grey-2;
  1661. border-radius: 0;
  1662. border: 0;
  1663. }
  1664. input[type="range"]::-webkit-slider-thumb {
  1665. box-shadow: 0;
  1666. border: 0;
  1667. height: 19px;
  1668. width: 19px;
  1669. border-radius: 15px;
  1670. background: $primary-color;
  1671. cursor: pointer;
  1672. -webkit-appearance: none;
  1673. margin-top: -6.5px;
  1674. }
  1675. input[type="range"]::-moz-range-track {
  1676. width: 100%;
  1677. height: 5.2px;
  1678. cursor: pointer;
  1679. box-shadow: 0;
  1680. background: $light-grey-2;
  1681. border-radius: 0;
  1682. border: 0;
  1683. }
  1684. input[type="range"]::-moz-range-thumb {
  1685. box-shadow: 0;
  1686. border: 0;
  1687. height: 19px;
  1688. width: 19px;
  1689. border-radius: 15px;
  1690. background: $primary-color;
  1691. cursor: pointer;
  1692. -webkit-appearance: none;
  1693. margin-top: -6.5px;
  1694. }
  1695. input[type="range"]::-ms-track {
  1696. width: 100%;
  1697. height: 5.2px;
  1698. cursor: pointer;
  1699. box-shadow: 0;
  1700. background: $light-grey-2;
  1701. border-radius: 1.3px;
  1702. }
  1703. input[type="range"]::-ms-fill-lower {
  1704. background: $light-grey-2;
  1705. border: 0;
  1706. border-radius: 0;
  1707. box-shadow: 0;
  1708. }
  1709. input[type="range"]::-ms-fill-upper {
  1710. background: $light-grey-2;
  1711. border: 0;
  1712. border-radius: 0;
  1713. box-shadow: 0;
  1714. }
  1715. input[type="range"]::-ms-thumb {
  1716. box-shadow: 0;
  1717. border: 0;
  1718. height: 15px;
  1719. width: 15px;
  1720. border-radius: 15px;
  1721. background: $primary-color;
  1722. cursor: pointer;
  1723. -webkit-appearance: none;
  1724. margin-top: 1.5px;
  1725. }
  1726. }
  1727. #right-buttons {
  1728. display: flex;
  1729. #dropdown-toggle {
  1730. width: 35px;
  1731. }
  1732. #dislike-song,
  1733. #add-song-to-playlist .button:not(#dropdown-toggle) {
  1734. margin-left: 5px;
  1735. }
  1736. #ratings {
  1737. display: flex;
  1738. #like-song:hover,
  1739. #like-song.liked {
  1740. background-color: darken($green, 5%) !important;
  1741. }
  1742. #dislike-song:hover,
  1743. #dislike-song.disliked {
  1744. background-color: darken($red, 5%) !important;
  1745. }
  1746. &.liked #dislike-song,
  1747. &.disliked #like-song {
  1748. background-color: $grey !important;
  1749. &:hover {
  1750. background-color: darken(
  1751. $grey,
  1752. 5%
  1753. ) !important;
  1754. }
  1755. }
  1756. }
  1757. #add-song-to-playlist {
  1758. display: flex;
  1759. flex-direction: column-reverse;
  1760. align-items: center;
  1761. width: 212px;
  1762. .control {
  1763. width: fit-content;
  1764. margin-bottom: 0 !important;
  1765. }
  1766. }
  1767. }
  1768. }
  1769. }
  1770. #sidebar-container {
  1771. position: relative;
  1772. width: 550px;
  1773. height: inherit;
  1774. margin-left: 50px;
  1775. }
  1776. }
  1777. }
  1778. }
  1779. /deep/ .nothing-here {
  1780. display: flex;
  1781. align-items: center;
  1782. justify-content: center;
  1783. text-transform: uppercase;
  1784. }
  1785. </style>