Station.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  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. }
  404. // UNIX client time before ping
  405. let beforePing = Date.now();
  406. _this.socket.emit('apis.ping', res => {
  407. // UNIX client time after ping
  408. let afterPing = Date.now();
  409. // Average time in MS it took between the server responding and the client receiving
  410. let connectionLatency = (afterPing - beforePing) / 2;
  411. console.log(connectionLatency, beforePing - afterPing);
  412. // UNIX server time
  413. let serverDate = res.date;
  414. // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
  415. let difference = (serverDate + connectionLatency) - afterPing;
  416. console.log("Difference: ", difference);
  417. if (difference > 3000 || difference < -3000) {
  418. console.log("System time difference is bigger than 3 seconds.");
  419. }
  420. _this.systemDifference = difference;
  421. });
  422. });
  423. }
  424. },
  425. ready: function() {
  426. let _this = this;
  427. Date.currently = () => {
  428. return new Date().getTime() + _this.systemDifference;
  429. };
  430. _this.stationName = _this.$route.params.id;
  431. window.stationInterval = 0;
  432. io.getSocket(socket => {
  433. _this.socket = socket;
  434. io.removeAllListeners();
  435. if (_this.socket.connected) _this.joinStation();
  436. io.onConnect(() => {
  437. _this.joinStation();
  438. });
  439. _this.socket.emit('stations.findByName', _this.stationName, res => {
  440. if (res.status === 'error') {
  441. _this.$router.go('/404');
  442. Toast.methods.addToast(res.message, 3000);
  443. }
  444. });
  445. _this.socket.on('event:songs.next', data => {
  446. _this.previousSong = (_this.currentSong.songId) ? _this.currentSong : null;
  447. _this.currentSong = (data.currentSong) ? data.currentSong : {};
  448. _this.startedAt = data.startedAt;
  449. _this.paused = data.paused;
  450. _this.timePaused = data.timePaused;
  451. if (data.currentSong) {
  452. _this.noSong = false;
  453. _this.simpleSong = (data.currentSong.likes === -1 && data.currentSong.dislikes === -1);
  454. if (_this.simpleSong) _this.currentSong.skipDuration = 0;
  455. if (!_this.playerReady) _this.youtubeReady();
  456. else _this.playVideo();
  457. _this.socket.emit('songs.getOwnSongRatings', data.currentSong._id, (data) => {
  458. if (_this.currentSong.songId === data.songId) {
  459. _this.liked = data.liked;
  460. _this.disliked = data.disliked;
  461. }
  462. });
  463. } else {
  464. if (_this.playerReady) _this.player.pauseVideo();
  465. _this.noSong = true;
  466. }
  467. let isInQueue = false;
  468. let userId = _this.$parent.userId;
  469. _this.songsList.forEach((queueSong) => {
  470. if (queueSong.requestedBy === userId) isInQueue = true;
  471. });
  472. if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong.songId || !_this.currentSong.songId)) {
  473. _this.addFirstPrivatePlaylistSongToQueue();
  474. }
  475. });
  476. _this.socket.on('event:stations.pause', data => {
  477. _this.pauseLocalStation();
  478. });
  479. _this.socket.on('event:stations.resume', data => {
  480. _this.timePaused = data.timePaused;
  481. _this.resumeLocalStation();
  482. });
  483. _this.socket.on('event:stations.remove', () => {
  484. location.href = '/';
  485. });
  486. _this.socket.on('event:song.like', data => {
  487. if (!this.noSong) {
  488. if (data.songId === _this.currentSong.songId) {
  489. _this.currentSong.dislikes = data.dislikes;
  490. _this.currentSong.likes = data.likes;
  491. }
  492. }
  493. });
  494. _this.socket.on('event:song.dislike', data => {
  495. if (!this.noSong) {
  496. if (data.songId === _this.currentSong.songId) {
  497. _this.currentSong.dislikes = data.dislikes;
  498. _this.currentSong.likes = data.likes;
  499. }
  500. }
  501. });
  502. _this.socket.on('event:song.unlike', data => {
  503. if (!this.noSong) {
  504. if (data.songId === _this.currentSong.songId) {
  505. _this.currentSong.dislikes = data.dislikes;
  506. _this.currentSong.likes = data.likes;
  507. }
  508. }
  509. });
  510. _this.socket.on('event:song.undislike', data => {
  511. if (!this.noSong) {
  512. if (data.songId === _this.currentSong.songId) {
  513. _this.currentSong.dislikes = data.dislikes;
  514. _this.currentSong.likes = data.likes;
  515. }
  516. }
  517. });
  518. _this.socket.on('event:song.newRatings', data => {
  519. if (!this.noSong) {
  520. if (data.songId === _this.currentSong.songId) {
  521. _this.liked = data.liked;
  522. _this.disliked = data.disliked;
  523. }
  524. }
  525. });
  526. _this.socket.on('event:queue.update', queue => {
  527. if (this.type === 'community') this.songsList = queue;
  528. });
  529. _this.socket.on('event:song.voteSkipSong', () => {
  530. if (this.currentSong) this.currentSong.skipVotes++;
  531. });
  532. _this.socket.on('event:privatePlaylist.selected', (playlistId) => {
  533. if (this.type === 'community') {
  534. this.station.privatePlaylist = playlistId;
  535. }
  536. });
  537. _this.socket.on('event:partyMode.updated', (partyMode) => {
  538. if (this.type === 'community') {
  539. this.station.partyMode = partyMode;
  540. }
  541. });
  542. _this.socket.on('event:newOfficialPlaylist', (playlist) => {
  543. console.log(playlist);
  544. if (this.type === 'official') {
  545. this.songsList = playlist;
  546. }
  547. });
  548. _this.socket.on('event:users.updated', users => {
  549. _this.users = users;
  550. });
  551. _this.socket.on('event:userCount.updated', userCount => {
  552. _this.userCount = userCount;
  553. });
  554. });
  555. let volume = parseInt(localStorage.getItem("volume"));
  556. volume = (typeof volume === "number" && !isNaN(volume)) ? volume : 20;
  557. localStorage.setItem("volume", volume);
  558. $("#volumeSlider").val(volume);
  559. },
  560. components: {
  561. OfficialHeader,
  562. CommunityHeader,
  563. SongQueue,
  564. EditPlaylist,
  565. CreatePlaylist,
  566. EditStation,
  567. Report,
  568. SongsListSidebar,
  569. PlaylistSidebar,
  570. UsersSidebar,
  571. MainFooter
  572. }
  573. }
  574. </script>
  575. <style lang="scss">
  576. .no-song {
  577. color: #03A9F4;
  578. text-align: center;
  579. }
  580. #volumeSlider {
  581. padding: 0 15px;
  582. background: transparent;
  583. }
  584. .volume-slider-wrapper {
  585. margin-top: 0;
  586. position: relative;
  587. display: flex;
  588. align-items: center;
  589. }
  590. .material-icons { cursor: pointer; }
  591. .stationDisplayName {
  592. color: white !important;
  593. }
  594. .slideout {
  595. top: 50px;
  596. height: 100%;
  597. position: fixed;
  598. right: 0;
  599. width: 350px;
  600. background-color: white;
  601. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  602. .slideout-header {
  603. text-align: center;
  604. background-color: rgb(3, 169, 244) !important;
  605. margin: 0;
  606. padding-top: 5px;
  607. padding-bottom: 7px;
  608. color: white;
  609. }
  610. .slideout-content {
  611. height: 100%;
  612. }
  613. }
  614. .modal-large {
  615. width: 75%;
  616. }
  617. .station {
  618. flex: 1 0 auto;
  619. padding-top: 0.5vw;
  620. transition: all 0.1s;
  621. margin: 0 auto;
  622. max-width: 1280px;
  623. width: 90%;
  624. @media only screen and (min-width: 993px) {
  625. width: 70%;
  626. }
  627. @media only screen and (min-width: 601px) {
  628. width: 85%;
  629. }
  630. input[type=range] {
  631. -webkit-appearance: none;
  632. width: 100%;
  633. margin: 7.3px 0;
  634. }
  635. input[type=range]:focus {
  636. outline: none;
  637. }
  638. input[type=range]::-webkit-slider-runnable-track {
  639. width: 100%;
  640. height: 5.2px;
  641. cursor: pointer;
  642. box-shadow: 0;
  643. background: #c2c0c2;
  644. border-radius: 0;
  645. border: 0;
  646. }
  647. input[type=range]::-webkit-slider-thumb {
  648. box-shadow: 0;
  649. border: 0;
  650. height: 19px;
  651. width: 19px;
  652. border-radius: 15px;
  653. background: #03a9f4;
  654. cursor: pointer;
  655. -webkit-appearance: none;
  656. margin-top: -6.5px;
  657. }
  658. input[type=range]::-moz-range-track {
  659. width: 100%;
  660. height: 5.2px;
  661. cursor: pointer;
  662. box-shadow: 0;
  663. background: #c2c0c2;
  664. border-radius: 0;
  665. border: 0;
  666. }
  667. input[type=range]::-moz-range-thumb {
  668. box-shadow: 0;
  669. border: 0;
  670. height: 19px;
  671. width: 19px;
  672. border-radius: 15px;
  673. background: #03a9f4;
  674. cursor: pointer;
  675. -webkit-appearance: none;
  676. margin-top: -6.5px;
  677. }
  678. input[type=range]::-ms-track {
  679. width: 100%;
  680. height: 5.2px;
  681. cursor: pointer;
  682. box-shadow: 0;
  683. background: #c2c0c2;
  684. border-radius: 1.3px;
  685. }
  686. input[type=range]::-ms-fill-lower {
  687. background: #c2c0c2;
  688. border: 0;
  689. border-radius: 0;
  690. box-shadow: 0;
  691. }
  692. input[type=range]::-ms-fill-upper {
  693. background: #c2c0c2;
  694. border: 0;
  695. border-radius: 0;
  696. box-shadow: 0;
  697. }
  698. input[type=range]::-ms-thumb {
  699. box-shadow: 0;
  700. border: 0;
  701. height: 15px;
  702. width: 15px;
  703. border-radius: 15px;
  704. background: #03a9f4;
  705. cursor: pointer;
  706. -webkit-appearance: none;
  707. margin-top: 1.5px;
  708. }
  709. .video-container {
  710. position: relative;
  711. padding-bottom: 56.25%;
  712. height: 0;
  713. overflow: hidden;
  714. iframe {
  715. position: absolute;
  716. top: 0;
  717. left: 0;
  718. width: 100%;
  719. height: 100%;
  720. }
  721. }
  722. .video-col {
  723. padding-right: 0.75rem;
  724. padding-left: 0.75rem;
  725. }
  726. }
  727. .room-title {
  728. left: 50%;
  729. -webkit-transform: translateX(-50%);
  730. transform: translateX(-50%);
  731. font-size: 2.1em;
  732. }
  733. #ratings {
  734. span {
  735. font-size: 1.68rem;
  736. }
  737. i {
  738. color: #9e9e9e !important;
  739. cursor: pointer;
  740. transition: 0.1s color;
  741. }
  742. }
  743. #time-display {
  744. margin-top: 30px;
  745. float: right;
  746. }
  747. #thumbs_up:hover, #thumbs_up.liked {
  748. color: #87D37C !important;
  749. }
  750. #thumbs_down:hover, #thumbs_down.disliked {
  751. color: #EC644B !important;
  752. }
  753. #song-thumbnail {
  754. max-width: 100%;
  755. width: 85%;
  756. }
  757. .seeker-bar-container {
  758. position: relative;
  759. height: 5px;
  760. display: block;
  761. width: 100%;
  762. overflow: hidden;
  763. }
  764. .seeker-bar {
  765. top: 0;
  766. left: 0;
  767. bottom: 0;
  768. position: absolute;
  769. }
  770. ul {
  771. list-style: none;
  772. margin: 0;
  773. display: block;
  774. }
  775. h1, h2, h3, h4, h5, h6 {
  776. font-weight: 400;
  777. line-height: 1.1;
  778. }
  779. h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  780. font-weight: inherit;
  781. }
  782. h1 {
  783. font-size: 4.2rem;
  784. line-height: 110%;
  785. margin: 2.1rem 0 1.68rem 0;
  786. }
  787. h2 {
  788. font-size: 3.56rem;
  789. line-height: 110%;
  790. margin: 1.78rem 0 1.424rem 0;
  791. }
  792. h3 {
  793. font-size: 2.92rem;
  794. line-height: 110%;
  795. margin: 1.46rem 0 1.168rem 0;
  796. }
  797. h4 {
  798. font-size: 2.28rem;
  799. line-height: 110%;
  800. margin: 1.14rem 0 0.912rem 0;
  801. }
  802. h5 {
  803. font-size: 1.64rem;
  804. line-height: 110%;
  805. margin: 0.82rem 0 0.656rem 0;
  806. }
  807. h6 {
  808. font-size: 1rem;
  809. line-height: 110%;
  810. margin: 0.5rem 0 0.4rem 0;
  811. }
  812. .thin {
  813. font-weight: 200;
  814. }
  815. .left {
  816. float: left !important;
  817. }
  818. .right {
  819. float: right !important;
  820. }
  821. .light-blue {
  822. background-color: #03a9f4 !important;
  823. }
  824. .white {
  825. background-color: #FFFFFF !important;
  826. }
  827. .btn-search {
  828. font-size: 14px;
  829. }
  830. .menu { padding: 0 10px; }
  831. .menu-list li a:hover { color: #000 !important; }
  832. .menu-list li {
  833. display: flex;
  834. justify-content: space-between;
  835. }
  836. .menu-list a {
  837. /*padding: 0 10px !important;*/
  838. }
  839. .menu-list a:hover {
  840. background-color : transparent;
  841. }
  842. .icons-group { display: flex; }
  843. #like, #dislike {
  844. position: relative;
  845. }
  846. .behind {
  847. z-index: -1;
  848. }
  849. .behind:focus {
  850. z-index: 0;
  851. }
  852. </style>