index.vue 47 KB

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