Station.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  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:stations.remove', () => {
  483. location.href = '/';
  484. });
  485. _this.socket.on('event:song.like', data => {
  486. if (!this.noSong) {
  487. if (data.songId === _this.currentSong.songId) {
  488. _this.currentSong.dislikes = data.dislikes;
  489. _this.currentSong.likes = data.likes;
  490. }
  491. }
  492. });
  493. _this.socket.on('event:song.dislike', data => {
  494. if (!this.noSong) {
  495. if (data.songId === _this.currentSong.songId) {
  496. _this.currentSong.dislikes = data.dislikes;
  497. _this.currentSong.likes = data.likes;
  498. }
  499. }
  500. });
  501. _this.socket.on('event:song.unlike', data => {
  502. if (!this.noSong) {
  503. if (data.songId === _this.currentSong.songId) {
  504. _this.currentSong.dislikes = data.dislikes;
  505. _this.currentSong.likes = data.likes;
  506. }
  507. }
  508. });
  509. _this.socket.on('event:song.undislike', data => {
  510. if (!this.noSong) {
  511. if (data.songId === _this.currentSong.songId) {
  512. _this.currentSong.dislikes = data.dislikes;
  513. _this.currentSong.likes = data.likes;
  514. }
  515. }
  516. });
  517. _this.socket.on('event:song.newRatings', data => {
  518. if (!this.noSong) {
  519. if (data.songId === _this.currentSong.songId) {
  520. _this.liked = data.liked;
  521. _this.disliked = data.disliked;
  522. }
  523. }
  524. });
  525. _this.socket.on('event:queue.update', queue => {
  526. if (this.type === 'community') this.songsList = queue;
  527. });
  528. _this.socket.on('event:song.voteSkipSong', () => {
  529. if (this.currentSong) this.currentSong.skipVotes++;
  530. });
  531. _this.socket.on('event:privatePlaylist.selected', (playlistId) => {
  532. if (this.type === 'community') {
  533. this.station.privatePlaylist = playlistId;
  534. }
  535. });
  536. _this.socket.on('event:partyMode.updated', (partyMode) => {
  537. if (this.type === 'community') {
  538. this.station.partyMode = partyMode;
  539. }
  540. });
  541. _this.socket.on('event:newOfficialPlaylist', (playlist) => {
  542. console.log(playlist);
  543. if (this.type === 'official') {
  544. this.songsList = playlist;
  545. }
  546. });
  547. _this.socket.on('event:users.updated', users => {
  548. _this.users = users;
  549. });
  550. _this.socket.on('event:userCount.updated', userCount => {
  551. _this.userCount = userCount;
  552. });
  553. });
  554. let volume = parseInt(localStorage.getItem("volume"));
  555. volume = (typeof volume === "number" && !isNaN(volume)) ? volume : 20;
  556. localStorage.setItem("volume", volume);
  557. $("#volumeSlider").val(volume);
  558. },
  559. components: {
  560. OfficialHeader,
  561. CommunityHeader,
  562. SongQueue,
  563. EditPlaylist,
  564. CreatePlaylist,
  565. EditStation,
  566. Report,
  567. SongsListSidebar,
  568. PlaylistSidebar,
  569. UsersSidebar
  570. }
  571. }
  572. </script>
  573. <style lang="scss">
  574. .no-song {
  575. color: #03A9F4;
  576. text-align: center;
  577. }
  578. #volumeSlider {
  579. padding: 0 15px;
  580. background: transparent;
  581. }
  582. .volume-slider-wrapper {
  583. margin-top: 0;
  584. position: relative;
  585. display: flex;
  586. align-items: center;
  587. }
  588. .material-icons { cursor: pointer; }
  589. .stationDisplayName {
  590. color: white !important;
  591. }
  592. .slideout {
  593. top: 50px;
  594. height: 100%;
  595. position: fixed;
  596. right: 0;
  597. width: 350px;
  598. background-color: white;
  599. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  600. .slideout-header {
  601. text-align: center;
  602. background-color: rgb(3, 169, 244) !important;
  603. margin: 0;
  604. padding-top: 5px;
  605. padding-bottom: 7px;
  606. color: white;
  607. }
  608. .slideout-content {
  609. height: 100%;
  610. }
  611. }
  612. .modal-large {
  613. width: 75%;
  614. }
  615. .station {
  616. flex: 1 0 auto;
  617. padding-top: 0.5vw;
  618. transition: all 0.1s;
  619. margin: 0 auto;
  620. max-width: 1280px;
  621. width: 90%;
  622. @media only screen and (min-width: 993px) {
  623. width: 70%;
  624. }
  625. @media only screen and (min-width: 601px) {
  626. width: 85%;
  627. }
  628. input[type=range] {
  629. -webkit-appearance: none;
  630. width: 100%;
  631. margin: 7.3px 0;
  632. }
  633. input[type=range]:focus {
  634. outline: none;
  635. }
  636. input[type=range]::-webkit-slider-runnable-track {
  637. width: 100%;
  638. height: 5.2px;
  639. cursor: pointer;
  640. box-shadow: 0;
  641. background: #c2c0c2;
  642. border-radius: 0;
  643. border: 0;
  644. }
  645. input[type=range]::-webkit-slider-thumb {
  646. box-shadow: 0;
  647. border: 0;
  648. height: 19px;
  649. width: 19px;
  650. border-radius: 15px;
  651. background: #03a9f4;
  652. cursor: pointer;
  653. -webkit-appearance: none;
  654. margin-top: -6.5px;
  655. }
  656. input[type=range]::-moz-range-track {
  657. width: 100%;
  658. height: 5.2px;
  659. cursor: pointer;
  660. box-shadow: 0;
  661. background: #c2c0c2;
  662. border-radius: 0;
  663. border: 0;
  664. }
  665. input[type=range]::-moz-range-thumb {
  666. box-shadow: 0;
  667. border: 0;
  668. height: 19px;
  669. width: 19px;
  670. border-radius: 15px;
  671. background: #03a9f4;
  672. cursor: pointer;
  673. -webkit-appearance: none;
  674. margin-top: -6.5px;
  675. }
  676. input[type=range]::-ms-track {
  677. width: 100%;
  678. height: 5.2px;
  679. cursor: pointer;
  680. box-shadow: 0;
  681. background: #c2c0c2;
  682. border-radius: 1.3px;
  683. }
  684. input[type=range]::-ms-fill-lower {
  685. background: #c2c0c2;
  686. border: 0;
  687. border-radius: 0;
  688. box-shadow: 0;
  689. }
  690. input[type=range]::-ms-fill-upper {
  691. background: #c2c0c2;
  692. border: 0;
  693. border-radius: 0;
  694. box-shadow: 0;
  695. }
  696. input[type=range]::-ms-thumb {
  697. box-shadow: 0;
  698. border: 0;
  699. height: 15px;
  700. width: 15px;
  701. border-radius: 15px;
  702. background: #03a9f4;
  703. cursor: pointer;
  704. -webkit-appearance: none;
  705. margin-top: 1.5px;
  706. }
  707. .video-container {
  708. position: relative;
  709. padding-bottom: 56.25%;
  710. height: 0;
  711. overflow: hidden;
  712. iframe {
  713. position: absolute;
  714. top: 0;
  715. left: 0;
  716. width: 100%;
  717. height: 100%;
  718. }
  719. }
  720. .video-col {
  721. padding-right: 0.75rem;
  722. padding-left: 0.75rem;
  723. }
  724. }
  725. .room-title {
  726. left: 50%;
  727. -webkit-transform: translateX(-50%);
  728. transform: translateX(-50%);
  729. font-size: 2.1em;
  730. }
  731. #ratings {
  732. span {
  733. font-size: 1.68rem;
  734. }
  735. i {
  736. color: #9e9e9e !important;
  737. cursor: pointer;
  738. transition: 0.1s color;
  739. }
  740. }
  741. #time-display {
  742. margin-top: 30px;
  743. float: right;
  744. }
  745. #thumbs_up:hover, #thumbs_up.liked {
  746. color: #87D37C !important;
  747. }
  748. #thumbs_down:hover, #thumbs_down.disliked {
  749. color: #EC644B !important;
  750. }
  751. #song-thumbnail {
  752. max-width: 100%;
  753. width: 85%;
  754. }
  755. .seeker-bar-container {
  756. position: relative;
  757. height: 5px;
  758. display: block;
  759. width: 100%;
  760. overflow: hidden;
  761. }
  762. .seeker-bar {
  763. top: 0;
  764. left: 0;
  765. bottom: 0;
  766. position: absolute;
  767. }
  768. ul {
  769. list-style: none;
  770. margin: 0;
  771. display: block;
  772. }
  773. h1, h2, h3, h4, h5, h6 {
  774. font-weight: 400;
  775. line-height: 1.1;
  776. }
  777. h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  778. font-weight: inherit;
  779. }
  780. h1 {
  781. font-size: 4.2rem;
  782. line-height: 110%;
  783. margin: 2.1rem 0 1.68rem 0;
  784. }
  785. h2 {
  786. font-size: 3.56rem;
  787. line-height: 110%;
  788. margin: 1.78rem 0 1.424rem 0;
  789. }
  790. h3 {
  791. font-size: 2.92rem;
  792. line-height: 110%;
  793. margin: 1.46rem 0 1.168rem 0;
  794. }
  795. h4 {
  796. font-size: 2.28rem;
  797. line-height: 110%;
  798. margin: 1.14rem 0 0.912rem 0;
  799. }
  800. h5 {
  801. font-size: 1.64rem;
  802. line-height: 110%;
  803. margin: 0.82rem 0 0.656rem 0;
  804. }
  805. h6 {
  806. font-size: 1rem;
  807. line-height: 110%;
  808. margin: 0.5rem 0 0.4rem 0;
  809. }
  810. .thin {
  811. font-weight: 200;
  812. }
  813. .left {
  814. float: left !important;
  815. }
  816. .right {
  817. float: right !important;
  818. }
  819. .light-blue {
  820. background-color: #03a9f4 !important;
  821. }
  822. .white {
  823. background-color: #FFFFFF !important;
  824. }
  825. .btn-search {
  826. font-size: 14px;
  827. }
  828. .menu { padding: 0 10px; }
  829. .menu-list li a:hover { color: #000 !important; }
  830. .menu-list li {
  831. display: flex;
  832. justify-content: space-between;
  833. }
  834. .menu-list a {
  835. /*padding: 0 10px !important;*/
  836. }
  837. .menu-list a:hover {
  838. background-color : transparent;
  839. }
  840. .icons-group { display: flex; }
  841. #like, #dislike {
  842. position: relative;
  843. }
  844. .behind {
  845. z-index: -1;
  846. }
  847. .behind:focus {
  848. z-index: 0;
  849. }
  850. </style>