Station.vue 29 KB

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