Station.vue 26 KB

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