Station.vue 29 KB

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