Station.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. <template>
  2. <official-header v-if='type == "official"'></official-header>
  3. <community-header v-if='type == "community"'></community-header>
  4. <song-queue v-if='modals.addSongToQueue'></song-queue>
  5. <edit-playlist v-if='modals.editPlaylist'></edit-playlist>
  6. <create-playlist v-if='modals.createPlaylist'></create-playlist>
  7. <edit-station v-show='modals.editStation'></edit-station>
  8. <report v-if='modals.report'></report>
  9. <songs-list-sidebar v-if='sidebars.songslist'></songs-list-sidebar>
  10. <playlist-sidebar v-if='sidebars.playlist'></playlist-sidebar>
  11. <users-sidebar v-if='sidebars.users'></users-sidebar>
  12. <div class="station">
  13. <div v-show="noSong" class="no-song">
  14. <h1>No song is currently playing</h1>
  15. <h4 v-if='type === "community" && station.partyMode'>
  16. <a href='#' class='no-song' @click='modals.addSongToQueue = true'>Add a song to the queue</a>
  17. </h4>
  18. <h4 v-if='type === "community" && !station.partyMode && $parent.userId === station.owner && !station.privatePlaylist'>
  19. <a href='#' class='no-song' @click='sidebars.playlist = true'>Play a private playlist</a>
  20. </h4>
  21. <h1 v-if='type === "community" && !station.partyMode && $parent.userId === station.owner && station.privatePlaylist'>Maybe you can add some songs to your selected private playlist and then press the skip button</h1>
  22. </div>
  23. <div class="columns is-mobile" v-show="!noSong">
  24. <div class="column is-8-desktop is-offset-2-desktop is-12-mobile">
  25. <div class="video-container">
  26. <div id="player"></div>
  27. <div class="seeker-bar-container white" id="preview-progress">
  28. <div class="seeker-bar light-blue" style="width: 0%;"></div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="columns is-mobile" v-show="!noSong">
  34. <div class="column is-8-desktop is-offset-2-desktop is-12-mobile">
  35. <div class="columns is-mobile">
  36. <div class="column is-12-mobile" v-bind:class="{'is-8-desktop': !simpleSong}">
  37. <h4 id="time-display">{{timeElapsed}} / {{formatTime(currentSong.duration)}}</h4>
  38. <h3>{{currentSong.title}}</h3>
  39. <h4 class="thin" style="margin-left: 0">{{currentSong.artists}}</h4>
  40. <div class="columns is-mobile">
  41. <form style="margin-top: 12px; margin-bottom: 0;" action="#" class="column is-7-desktop is-4-mobile">
  42. <p class='volume-slider-wrapper'>
  43. <i class="material-icons" @click='toggleMute()' v-if='muted'>volume_mute</i>
  44. <i class="material-icons" @click='toggleMute()' v-else>volume_down</i>
  45. <input type="range" id="volumeSlider" min="0" max="100" class="active" v-on:change="changeVolume()" v-on:input="changeVolume()">
  46. <i class="material-icons" @click='increaseVolume()'>volume_up</i>
  47. </p>
  48. </form>
  49. <div class="column is-8-mobile is-5-desktop" style="float: right;">
  50. <ul id="ratings" v-if="currentSong.likes !== -1 && currentSong.dislikes !== -1">
  51. <li id="like" class="right" @click="toggleLike()">
  52. <span class="flow-text">{{currentSong.likes}} </span>
  53. <i id="thumbs_up" class="material-icons grey-text" v-bind:class="{ liked: liked }">thumb_up</i>
  54. <a class='absolute-a behind' @click="toggleLike()" href='#'></a>
  55. </li>
  56. <li style="margin-right: 10px;" id="dislike" class="right" @click="toggleDislike()">
  57. <span class="flow-text">{{currentSong.dislikes}} </span>
  58. <i id="thumbs_down" class="material-icons grey-text" v-bind:class="{ disliked: disliked }">thumb_down</i>
  59. <a class='absolute-a behind' @click="toggleDislike()" href='#'></a>
  60. </li>
  61. </ul>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="column is-4-desktop" v-if="!simpleSong">
  66. <img class="image" id="song-thumbnail" style="margin-top: 10px !important" :src="currentSong.thumbnail" alt="Song Thumbnail" onerror="this.src='/assets/notes-transparent.png'" />
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import { Toast } from 'vue-roaster';
  75. import SongQueue from '../Modals/AddSongToQueue.vue';
  76. import EditPlaylist from '../Modals/Playlists/Edit.vue';
  77. import CreatePlaylist from '../Modals/Playlists/Create.vue';
  78. import EditStation from '../Modals/EditStation.vue';
  79. import Report from '../Modals/Report.vue';
  80. import SongsListSidebar from '../Sidebars/SongsList.vue';
  81. import PlaylistSidebar from '../Sidebars/Playlist.vue';
  82. import UsersSidebar from '../Sidebars/UsersList.vue';
  83. import OfficialHeader from './OfficialHeader.vue';
  84. import CommunityHeader from './CommunityHeader.vue';
  85. import MainFooter from '../MainFooter.vue';
  86. import io from '../../io';
  87. import auth from '../../auth';
  88. export default {
  89. data() {
  90. return {
  91. type: '',
  92. playerReady: false,
  93. previousSong: null,
  94. currentSong: {},
  95. player: undefined,
  96. timePaused: 0,
  97. paused: false,
  98. muted: false,
  99. timeElapsed: '0:00',
  100. liked: false,
  101. disliked: false,
  102. modals: {
  103. addSongToQueue: false,
  104. editPlaylist: false,
  105. createPlaylist: false,
  106. editStation: false,
  107. report: false
  108. },
  109. sidebars: {
  110. songslist: false,
  111. users: false,
  112. playlist: false
  113. },
  114. noSong: false,
  115. simpleSong: false,
  116. songsList: [],
  117. timeBeforePause: 0,
  118. station: {},
  119. skipVotes: 0,
  120. privatePlaylistQueueSelected: null,
  121. automaticallyRequestedSongId: null,
  122. systemDifference: 0,
  123. users: [],
  124. userCount: 0
  125. }
  126. },
  127. methods: {
  128. editPlaylist: function (id) {
  129. this.playlistBeingEdited = id;
  130. this.modals.editPlaylist = !this.modals.editPlaylist;
  131. },
  132. editStation: function () {
  133. let _this = this;
  134. this.$broadcast('editStation', {
  135. _id: _this.station._id,
  136. name: _this.station.name,
  137. type: _this.type,
  138. partyMode: _this.station.partyMode,
  139. description: _this.station.description,
  140. privacy: _this.station.privacy,
  141. displayName: _this.station.displayName
  142. });
  143. },
  144. toggleSidebar: function (type) {
  145. Object.keys(this.sidebars).forEach(sidebar => {
  146. if (sidebar !== type) this.sidebars[sidebar] = false;
  147. else this.sidebars[type] = !this.sidebars[type];
  148. });
  149. },
  150. youtubeReady: function() {
  151. let local = this;
  152. if (!local.player) {
  153. local.player = new YT.Player("player", {
  154. height: 270,
  155. width: 480,
  156. videoId: local.currentSong.songId,
  157. startSeconds: local.getTimeElapsed() / 1000 + local.currentSong.skipDuration,
  158. playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0},
  159. events: {
  160. 'onReady': function (event) {
  161. local.playerReady = true;
  162. let volume = parseInt(localStorage.getItem("volume"));
  163. volume = (typeof volume === "number") ? volume : 20;
  164. local.player.setVolume(volume);
  165. if (volume > 0) local.player.unMute();
  166. local.playVideo();
  167. },
  168. 'onError': function(err) {
  169. console.log("iframe error", err);
  170. local.voteSkipStation();
  171. },
  172. 'onStateChange': function (event) {
  173. if (event.data === 1 && local.videoLoading === true) {
  174. local.videoLoading = false;
  175. local.player.seekTo(local.getTimeElapsed() / 1000 + local.currentSong.skipDuration, true);
  176. if (local.paused) local.player.pauseVideo();
  177. } else if (event.data === 1 && local.paused) {
  178. local.player.seekTo(local.timeBeforePause / 1000, true);
  179. local.player.pauseVideo();
  180. }
  181. if (event.data === 2 && !local.paused && !local.noSong && (local.player.getDuration() / 1000) < local.currentSong.duration) {
  182. local.player.seekTo(local.getTimeElapsed() / 1000 + local.currentSong.skipDuration, true);
  183. local.player.playVideo();
  184. }
  185. }
  186. }
  187. });
  188. }
  189. },
  190. getTimeElapsed: function() {
  191. let local = this;
  192. if (local.currentSong) return Date.currently() - local.startedAt - local.timePaused;
  193. else return 0;
  194. },
  195. playVideo: function() {
  196. let local = this;
  197. if (local.playerReady) {
  198. local.videoLoading = true;
  199. local.player.loadVideoById(local.currentSong.songId, local.getTimeElapsed() / 1000 + local.currentSong.skipDuration);
  200. if (local.currentSong.artists) local.currentSong.artists = local.currentSong.artists.join(", ");
  201. if (window.stationInterval !== 0) clearInterval(window.stationInterval);
  202. window.stationInterval = setInterval(function () {
  203. local.resizeSeekerbar();
  204. local.calculateTimeElapsed();
  205. }, 250);
  206. }
  207. },
  208. resizeSeekerbar: function() {
  209. let local = this;
  210. if (!local.paused) {
  211. $(".seeker-bar").width(parseInt(((local.getTimeElapsed() / 1000) / local.currentSong.duration * 100)) + "%");
  212. }
  213. },
  214. formatTime: function(duration) {
  215. let d = moment.duration(duration, 'seconds');
  216. if (duration < 0) return "0:00";
  217. return ((d.hours() > 0) ? (d.hours() < 10 ? ("0" + d.hours() + ":") : (d.hours() + ":")) : "") + (d.minutes() + ":") + (d.seconds() < 10 ? ("0" + d.seconds()) : d.seconds());
  218. },
  219. calculateTimeElapsed: function() {
  220. let local = this;
  221. let currentTime = Date.currently();
  222. if (local.currentTime !== undefined && local.paused) {
  223. local.timePaused += (Date.currently() - local.currentTime);
  224. local.currentTime = undefined;
  225. }
  226. let duration = (Date.currently() - local.startedAt - local.timePaused) / 1000;
  227. let songDuration = local.currentSong.duration;
  228. if (songDuration <= duration) local.player.pauseVideo();
  229. if ((!local.paused) && duration <= songDuration) local.timeElapsed = local.formatTime(duration);
  230. },
  231. changeVolume: function() {
  232. let local = this;
  233. let volume = $("#volumeSlider").val();
  234. localStorage.setItem("volume", volume);
  235. if (local.playerReady) {
  236. local.player.setVolume(volume);
  237. if (volume > 0) local.player.unMute();
  238. }
  239. },
  240. resumeLocalStation: function() {
  241. this.paused = false;
  242. if (!this.noSong) {
  243. if (this.playerReady) {
  244. this.player.seekTo(this.getTimeElapsed() / 1000 + this.currentSong.skipDuration);
  245. this.player.playVideo();
  246. }
  247. }
  248. },
  249. pauseLocalStation: function() {
  250. this.paused = true;
  251. if (!this.noSong) {
  252. this.timeBeforePause = this.getTimeElapsed();
  253. if (this.playerReady) this.player.pauseVideo();
  254. }
  255. },
  256. skipStation: function () {
  257. let _this = this;
  258. _this.socket.emit('stations.forceSkip', _this.station._id, data => {
  259. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  260. else Toast.methods.addToast('Successfully skipped the station\'s current song.', 4000);
  261. });
  262. },
  263. voteSkipStation: function () {
  264. let _this = this;
  265. _this.socket.emit('stations.voteSkip', _this.station._id, data => {
  266. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  267. else Toast.methods.addToast('Successfully voted to skip the current song.', 4000);
  268. });
  269. },
  270. resumeStation: function () {
  271. let _this = this;
  272. _this.socket.emit('stations.resume', _this.station._id, data => {
  273. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  274. else Toast.methods.addToast('Successfully resumed the station.', 4000);
  275. });
  276. },
  277. pauseStation: function () {
  278. let _this = this;
  279. _this.socket.emit('stations.pause', _this.station._id, data => {
  280. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  281. else Toast.methods.addToast('Successfully paused the station.', 4000);
  282. });
  283. },
  284. toggleMute: function () {
  285. if (this.playerReady) {
  286. let previousVolume = parseInt(localStorage.getItem("volume"));
  287. let volume = this.player.getVolume() <= 0 ? previousVolume : 0;
  288. this.muted = !this.muted;
  289. $("#volumeSlider").val(volume);
  290. this.player.setVolume(volume);
  291. localStorage.setItem("volume", volume);
  292. }
  293. },
  294. increaseVolume: function () {
  295. if (this.playerReady) {
  296. let previousVolume = parseInt(localStorage.getItem("volume"));
  297. let volume = previousVolume + 5;
  298. if (previousVolume === 0) {
  299. this.muted = false;
  300. }
  301. if (volume > 100) {
  302. volume = 100;
  303. }
  304. console.log(previousVolume, volume);
  305. $("#volumeSlider").val(volume);
  306. this.player.setVolume(volume);
  307. localStorage.setItem("volume", volume);
  308. }
  309. },
  310. toggleLike: function() {
  311. let _this = this;
  312. if (_this.liked) _this.socket.emit('songs.unlike', _this.currentSong.songId, data => {
  313. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  314. }); else _this.socket.emit('songs.like', _this.currentSong.songId, data => {
  315. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  316. });
  317. },
  318. toggleDislike: function() {
  319. let _this = this;
  320. if (_this.disliked) return _this.socket.emit('songs.undislike', _this.currentSong.songId, data => {
  321. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  322. });
  323. _this.socket.emit('songs.dislike', _this.currentSong.songId, data => {
  324. if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
  325. });
  326. },
  327. addFirstPrivatePlaylistSongToQueue: function() {
  328. let _this = this;
  329. let isInQueue = false;
  330. let userId = _this.$parent.userId;
  331. if (_this.type === 'community') {
  332. _this.songsList.forEach((queueSong) => {
  333. if (queueSong.requestedBy === userId) isInQueue = true;
  334. });
  335. if (!isInQueue && _this.privatePlaylistQueueSelected) {
  336. _this.socket.emit('playlists.getFirstSong', _this.privatePlaylistQueueSelected, data => {
  337. if (data.status === 'success') {
  338. console.log(data.song);
  339. let songId = data.song._id;
  340. _this.automaticallyRequestedSongId = data.song.songId;
  341. _this.socket.emit('stations.addToQueue', _this.station._id, data.song.songId, data => {
  342. if (data.status === 'success') {
  343. _this.socket.emit('playlists.moveSongToBottom', _this.privatePlaylistQueueSelected, songId, data => {
  344. if (data.status === 'success') {}
  345. });
  346. }
  347. });
  348. }
  349. });
  350. }
  351. }
  352. },
  353. joinStation: function () {
  354. let _this = this;
  355. _this.socket.emit('stations.join', _this.stationName, res => {
  356. if (res.status === 'success') {
  357. _this.station = {
  358. _id: res.data._id,
  359. name: _this.stationName,
  360. displayName: res.data.displayName,
  361. description: res.data.description,
  362. privacy: res.data.privacy,
  363. partyMode: res.data.partyMode,
  364. owner: res.data.owner,
  365. privatePlaylist: res.data.privatePlaylist
  366. };
  367. console.log(res.data.currentSong);
  368. _this.currentSong = (res.data.currentSong) ? res.data.currentSong : {};
  369. _this.type = res.data.type;
  370. _this.startedAt = res.data.startedAt;
  371. _this.paused = res.data.paused;
  372. _this.timePaused = res.data.timePaused;
  373. _this.userCount = res.data.userCount;
  374. _this.users = res.data.users;
  375. if (res.data.currentSong) {
  376. _this.noSong = false;
  377. _this.simpleSong = (res.data.currentSong.likes === -1 && res.data.currentSong.dislikes === -1);
  378. if (_this.simpleSong) {
  379. _this.currentSong.skipDuration = 0;
  380. }
  381. _this.youtubeReady();
  382. _this.playVideo();
  383. _this.socket.emit('songs.getOwnSongRatings', res.data.currentSong._id, data => {
  384. if (_this.currentSong.songId === data.songId) {
  385. _this.liked = data.liked;
  386. _this.disliked = data.disliked;
  387. }
  388. });
  389. } else {
  390. if (_this.playerReady) _this.player.pauseVideo();
  391. _this.noSong = true;
  392. }
  393. if (_this.type === 'community') {
  394. _this.socket.emit('stations.getQueue', _this.station._id, data => {
  395. if (data.status === 'success') _this.songsList = data.queue;
  396. });
  397. }
  398. if (_this.type === 'official') {
  399. _this.socket.emit('stations.getPlaylist', _this.station._id, res => {
  400. if (res.status == 'success') _this.songsList = res.data;
  401. });
  402. }
  403. } else {
  404. _this.$router.go('/404');
  405. Toast.methods.addToast(res.message, 3000);
  406. }
  407. // UNIX client time before ping
  408. let beforePing = Date.now();
  409. _this.socket.emit('apis.ping', res => {
  410. // UNIX client time after ping
  411. let afterPing = Date.now();
  412. // Average time in MS it took between the server responding and the client receiving
  413. let connectionLatency = (afterPing - beforePing) / 2;
  414. console.log(connectionLatency, beforePing - afterPing);
  415. // UNIX server time
  416. let serverDate = res.date;
  417. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  418. let difference = (serverDate + connectionLatency) - afterPing;
  419. console.log("Difference: ", difference);
  420. if (difference > 3000 || difference < -3000) {
  421. console.log("System time difference is bigger than 3 seconds.");
  422. }
  423. _this.systemDifference = difference;
  424. });
  425. });
  426. }
  427. },
  428. ready: function() {
  429. let _this = this;
  430. Date.currently = () => {
  431. return new Date().getTime() + _this.systemDifference;
  432. };
  433. _this.stationName = _this.$route.params.id;
  434. window.stationInterval = 0;
  435. io.getSocket(socket => {
  436. _this.socket = socket;
  437. io.removeAllListeners();
  438. if (_this.socket.connected) _this.joinStation();
  439. io.onConnect(() => {
  440. _this.joinStation();
  441. });
  442. _this.socket.emit('stations.findByName', _this.stationName, res => {
  443. if (res.status === 'error') {
  444. _this.$router.go('/404');
  445. Toast.methods.addToast(res.message, 3000);
  446. }
  447. });
  448. _this.socket.on('event:songs.next', data => {
  449. _this.previousSong = (_this.currentSong.songId) ? _this.currentSong : null;
  450. _this.currentSong = (data.currentSong) ? data.currentSong : {};
  451. _this.startedAt = data.startedAt;
  452. _this.paused = data.paused;
  453. _this.timePaused = data.timePaused;
  454. if (data.currentSong) {
  455. _this.noSong = false;
  456. _this.simpleSong = (data.currentSong.likes === -1 && data.currentSong.dislikes === -1);
  457. if (_this.simpleSong) _this.currentSong.skipDuration = 0;
  458. if (!_this.playerReady) _this.youtubeReady();
  459. else _this.playVideo();
  460. _this.socket.emit('songs.getOwnSongRatings', data.currentSong._id, (data) => {
  461. if (_this.currentSong.songId === data.songId) {
  462. _this.liked = data.liked;
  463. _this.disliked = data.disliked;
  464. }
  465. });
  466. } else {
  467. if (_this.playerReady) _this.player.pauseVideo();
  468. _this.noSong = true;
  469. }
  470. let isInQueue = false;
  471. let userId = _this.$parent.userId;
  472. _this.songsList.forEach((queueSong) => {
  473. if (queueSong.requestedBy === userId) isInQueue = true;
  474. });
  475. if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong.songId || !_this.currentSong.songId)) {
  476. _this.addFirstPrivatePlaylistSongToQueue();
  477. }
  478. });
  479. _this.socket.on('event:stations.pause', data => {
  480. _this.pauseLocalStation();
  481. });
  482. _this.socket.on('event:stations.resume', data => {
  483. _this.timePaused = data.timePaused;
  484. _this.resumeLocalStation();
  485. });
  486. _this.socket.on('event:stations.remove', () => {
  487. location.href = '/';
  488. });
  489. _this.socket.on('event:song.like', data => {
  490. if (!this.noSong) {
  491. if (data.songId === _this.currentSong.songId) {
  492. _this.currentSong.dislikes = data.dislikes;
  493. _this.currentSong.likes = data.likes;
  494. }
  495. }
  496. });
  497. _this.socket.on('event:song.dislike', data => {
  498. if (!this.noSong) {
  499. if (data.songId === _this.currentSong.songId) {
  500. _this.currentSong.dislikes = data.dislikes;
  501. _this.currentSong.likes = data.likes;
  502. }
  503. }
  504. });
  505. _this.socket.on('event:song.unlike', data => {
  506. if (!this.noSong) {
  507. if (data.songId === _this.currentSong.songId) {
  508. _this.currentSong.dislikes = data.dislikes;
  509. _this.currentSong.likes = data.likes;
  510. }
  511. }
  512. });
  513. _this.socket.on('event:song.undislike', data => {
  514. if (!this.noSong) {
  515. if (data.songId === _this.currentSong.songId) {
  516. _this.currentSong.dislikes = data.dislikes;
  517. _this.currentSong.likes = data.likes;
  518. }
  519. }
  520. });
  521. _this.socket.on('event:song.newRatings', data => {
  522. if (!this.noSong) {
  523. if (data.songId === _this.currentSong.songId) {
  524. _this.liked = data.liked;
  525. _this.disliked = data.disliked;
  526. }
  527. }
  528. });
  529. _this.socket.on('event:queue.update', queue => {
  530. if (this.type === 'community') this.songsList = queue;
  531. });
  532. _this.socket.on('event:song.voteSkipSong', () => {
  533. if (this.currentSong) this.currentSong.skipVotes++;
  534. });
  535. _this.socket.on('event:privatePlaylist.selected', (playlistId) => {
  536. if (this.type === 'community') {
  537. this.station.privatePlaylist = playlistId;
  538. }
  539. });
  540. _this.socket.on('event:partyMode.updated', (partyMode) => {
  541. if (this.type === 'community') {
  542. this.station.partyMode = partyMode;
  543. }
  544. });
  545. _this.socket.on('event:newOfficialPlaylist', (playlist) => {
  546. console.log(playlist);
  547. if (this.type === 'official') {
  548. this.songsList = playlist;
  549. }
  550. });
  551. _this.socket.on('event:users.updated', users => {
  552. _this.users = users;
  553. });
  554. _this.socket.on('event:userCount.updated', userCount => {
  555. _this.userCount = userCount;
  556. });
  557. });
  558. let volume = parseInt(localStorage.getItem("volume"));
  559. volume = (typeof volume === "number" && !isNaN(volume)) ? volume : 20;
  560. localStorage.setItem("volume", volume);
  561. $("#volumeSlider").val(volume);
  562. },
  563. components: {
  564. OfficialHeader,
  565. CommunityHeader,
  566. SongQueue,
  567. EditPlaylist,
  568. CreatePlaylist,
  569. EditStation,
  570. Report,
  571. SongsListSidebar,
  572. PlaylistSidebar,
  573. UsersSidebar,
  574. MainFooter
  575. }
  576. }
  577. </script>
  578. <style lang="scss">
  579. .no-song {
  580. color: #03A9F4;
  581. text-align: center;
  582. }
  583. #volumeSlider {
  584. padding: 0 15px;
  585. background: transparent;
  586. }
  587. .volume-slider-wrapper {
  588. margin-top: 0;
  589. position: relative;
  590. display: flex;
  591. align-items: center;
  592. }
  593. .material-icons { cursor: pointer; }
  594. .stationDisplayName {
  595. color: white !important;
  596. }
  597. .slideout {
  598. top: 50px;
  599. height: 100%;
  600. position: fixed;
  601. right: 0;
  602. width: 350px;
  603. background-color: white;
  604. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  605. .slideout-header {
  606. text-align: center;
  607. background-color: rgb(3, 169, 244) !important;
  608. margin: 0;
  609. padding-top: 5px;
  610. padding-bottom: 7px;
  611. color: white;
  612. }
  613. .slideout-content {
  614. height: 100%;
  615. }
  616. }
  617. .modal-large {
  618. width: 75%;
  619. }
  620. .station {
  621. flex: 1 0 auto;
  622. padding-top: 0.5vw;
  623. transition: all 0.1s;
  624. margin: 0 auto;
  625. max-width: 1280px;
  626. width: 90%;
  627. @media only screen and (min-width: 993px) {
  628. width: 70%;
  629. }
  630. @media only screen and (min-width: 601px) {
  631. width: 85%;
  632. }
  633. input[type=range] {
  634. -webkit-appearance: none;
  635. width: 100%;
  636. margin: 7.3px 0;
  637. }
  638. input[type=range]:focus {
  639. outline: none;
  640. }
  641. input[type=range]::-webkit-slider-runnable-track {
  642. width: 100%;
  643. height: 5.2px;
  644. cursor: pointer;
  645. box-shadow: 0;
  646. background: #c2c0c2;
  647. border-radius: 0;
  648. border: 0;
  649. }
  650. input[type=range]::-webkit-slider-thumb {
  651. box-shadow: 0;
  652. border: 0;
  653. height: 19px;
  654. width: 19px;
  655. border-radius: 15px;
  656. background: #03a9f4;
  657. cursor: pointer;
  658. -webkit-appearance: none;
  659. margin-top: -6.5px;
  660. }
  661. input[type=range]::-moz-range-track {
  662. width: 100%;
  663. height: 5.2px;
  664. cursor: pointer;
  665. box-shadow: 0;
  666. background: #c2c0c2;
  667. border-radius: 0;
  668. border: 0;
  669. }
  670. input[type=range]::-moz-range-thumb {
  671. box-shadow: 0;
  672. border: 0;
  673. height: 19px;
  674. width: 19px;
  675. border-radius: 15px;
  676. background: #03a9f4;
  677. cursor: pointer;
  678. -webkit-appearance: none;
  679. margin-top: -6.5px;
  680. }
  681. input[type=range]::-ms-track {
  682. width: 100%;
  683. height: 5.2px;
  684. cursor: pointer;
  685. box-shadow: 0;
  686. background: #c2c0c2;
  687. border-radius: 1.3px;
  688. }
  689. input[type=range]::-ms-fill-lower {
  690. background: #c2c0c2;
  691. border: 0;
  692. border-radius: 0;
  693. box-shadow: 0;
  694. }
  695. input[type=range]::-ms-fill-upper {
  696. background: #c2c0c2;
  697. border: 0;
  698. border-radius: 0;
  699. box-shadow: 0;
  700. }
  701. input[type=range]::-ms-thumb {
  702. box-shadow: 0;
  703. border: 0;
  704. height: 15px;
  705. width: 15px;
  706. border-radius: 15px;
  707. background: #03a9f4;
  708. cursor: pointer;
  709. -webkit-appearance: none;
  710. margin-top: 1.5px;
  711. }
  712. .video-container {
  713. position: relative;
  714. padding-bottom: 56.25%;
  715. height: 0;
  716. overflow: hidden;
  717. iframe {
  718. position: absolute;
  719. top: 0;
  720. left: 0;
  721. width: 100%;
  722. height: 100%;
  723. }
  724. }
  725. .video-col {
  726. padding-right: 0.75rem;
  727. padding-left: 0.75rem;
  728. }
  729. }
  730. .room-title {
  731. left: 50%;
  732. -webkit-transform: translateX(-50%);
  733. transform: translateX(-50%);
  734. font-size: 2.1em;
  735. }
  736. #ratings {
  737. span {
  738. font-size: 1.68rem;
  739. }
  740. i {
  741. color: #9e9e9e !important;
  742. cursor: pointer;
  743. transition: 0.1s color;
  744. }
  745. }
  746. #time-display {
  747. margin-top: 30px;
  748. float: right;
  749. }
  750. #thumbs_up:hover, #thumbs_up.liked {
  751. color: #87D37C !important;
  752. }
  753. #thumbs_down:hover, #thumbs_down.disliked {
  754. color: #EC644B !important;
  755. }
  756. #song-thumbnail {
  757. max-width: 100%;
  758. width: 85%;
  759. }
  760. .seeker-bar-container {
  761. position: relative;
  762. height: 5px;
  763. display: block;
  764. width: 100%;
  765. overflow: hidden;
  766. }
  767. .seeker-bar {
  768. top: 0;
  769. left: 0;
  770. bottom: 0;
  771. position: absolute;
  772. }
  773. ul {
  774. list-style: none;
  775. margin: 0;
  776. display: block;
  777. }
  778. h1, h2, h3, h4, h5, h6 {
  779. font-weight: 400;
  780. line-height: 1.1;
  781. }
  782. h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  783. font-weight: inherit;
  784. }
  785. h1 {
  786. font-size: 4.2rem;
  787. line-height: 110%;
  788. margin: 2.1rem 0 1.68rem 0;
  789. }
  790. h2 {
  791. font-size: 3.56rem;
  792. line-height: 110%;
  793. margin: 1.78rem 0 1.424rem 0;
  794. }
  795. h3 {
  796. font-size: 2.92rem;
  797. line-height: 110%;
  798. margin: 1.46rem 0 1.168rem 0;
  799. }
  800. h4 {
  801. font-size: 2.28rem;
  802. line-height: 110%;
  803. margin: 1.14rem 0 0.912rem 0;
  804. }
  805. h5 {
  806. font-size: 1.64rem;
  807. line-height: 110%;
  808. margin: 0.82rem 0 0.656rem 0;
  809. }
  810. h6 {
  811. font-size: 1rem;
  812. line-height: 110%;
  813. margin: 0.5rem 0 0.4rem 0;
  814. }
  815. .thin {
  816. font-weight: 200;
  817. }
  818. .left {
  819. float: left !important;
  820. }
  821. .right {
  822. float: right !important;
  823. }
  824. .light-blue {
  825. background-color: #03a9f4 !important;
  826. }
  827. .white {
  828. background-color: #FFFFFF !important;
  829. }
  830. .btn-search {
  831. font-size: 14px;
  832. }
  833. .menu { padding: 0 10px; }
  834. .menu-list li a:hover { color: #000 !important; }
  835. .menu-list li {
  836. display: flex;
  837. justify-content: space-between;
  838. }
  839. .menu-list a {
  840. /*padding: 0 10px !important;*/
  841. }
  842. .menu-list a:hover {
  843. background-color : transparent;
  844. }
  845. .icons-group { display: flex; }
  846. #like, #dislike {
  847. position: relative;
  848. }
  849. .behind {
  850. z-index: -1;
  851. }
  852. .behind:focus {
  853. z-index: 0;
  854. }
  855. </style>