Station.vue 45 KB

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