index.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051
  1. <template>
  2. <div>
  3. <modal title="Edit Song" class="song-modal" :wide="true" :split="true">
  4. <template #body>
  5. <div class="left-section">
  6. <div class="top-section">
  7. <div class="player-section">
  8. <div id="editSongPlayer" />
  9. <div v-show="youtubeError" class="player-error">
  10. <h2>{{ youtubeErrorMessage }}</h2>
  11. </div>
  12. <canvas
  13. ref="durationCanvas"
  14. id="durationCanvas"
  15. v-show="!youtubeError"
  16. height="20"
  17. width="530"
  18. />
  19. <div class="player-footer">
  20. <div class="player-footer-left">
  21. <button
  22. class="button is-primary"
  23. @click="play()"
  24. @keyup.enter="play()"
  25. v-if="video.paused"
  26. content="Unpause Playback"
  27. v-tippy
  28. >
  29. <i class="material-icons">play_arrow</i>
  30. </button>
  31. <button
  32. class="button is-primary"
  33. @click="settings('pause')"
  34. @keyup.enter="settings('pause')"
  35. v-else
  36. content="Pause Playback"
  37. v-tippy
  38. >
  39. <i class="material-icons">pause</i>
  40. </button>
  41. <button
  42. class="button is-danger"
  43. @click="settings('stop')"
  44. @keyup.enter="settings('stop')"
  45. content="Stop Playback"
  46. v-tippy
  47. >
  48. <i class="material-icons">stop</i>
  49. </button>
  50. <button
  51. class="button is-success"
  52. @click="settings('skipToLast10Secs')"
  53. @keyup.enter="
  54. settings('skipToLast10Secs')
  55. "
  56. content="Skip to last 10 secs"
  57. v-tippy
  58. >
  59. <i class="material-icons"
  60. >fast_forward</i
  61. >
  62. </button>
  63. </div>
  64. <div class="player-footer-center">
  65. <span>
  66. <span>
  67. {{ youtubeVideoCurrentTime }}
  68. </span>
  69. /
  70. <span>
  71. {{ youtubeVideoDuration }}
  72. {{ youtubeVideoNote }}
  73. </span>
  74. </span>
  75. </div>
  76. <div class="player-footer-right">
  77. <p id="volume-control">
  78. <i
  79. v-if="muted"
  80. class="material-icons"
  81. @click="toggleMute()"
  82. content="Unmute"
  83. v-tippy
  84. >volume_mute</i
  85. >
  86. <i
  87. v-else
  88. class="material-icons"
  89. @click="toggleMute()"
  90. content="Mute"
  91. v-tippy
  92. >volume_down</i
  93. >
  94. <input
  95. v-model="volumeSliderValue"
  96. type="range"
  97. min="0"
  98. max="10000"
  99. class="volume-slider active"
  100. @change="changeVolume()"
  101. @input="changeVolume()"
  102. />
  103. <i
  104. class="material-icons"
  105. @click="increaseVolume()"
  106. content="Increase Volume"
  107. v-tippy
  108. >volume_up</i
  109. >
  110. </p>
  111. </div>
  112. </div>
  113. </div>
  114. <img
  115. class="thumbnail-preview"
  116. :src="song.thumbnail"
  117. onerror="this.src='/assets/notes-transparent.png'"
  118. ref="thumbnailElement"
  119. v-if="songDataLoaded"
  120. />
  121. </div>
  122. <div class="edit-section" v-if="songDataLoaded">
  123. <div class="control is-grouped">
  124. <div class="title-container">
  125. <label class="label">Title</label>
  126. <p class="control has-addons">
  127. <input
  128. class="input"
  129. type="text"
  130. ref="title-input"
  131. v-model="song.title"
  132. placeholder="Enter song title..."
  133. @keyup.shift.enter="
  134. getAlbumData('title')
  135. "
  136. />
  137. <button
  138. class="button album-get-button"
  139. @click="getAlbumData('title')"
  140. >
  141. <i
  142. class="material-icons"
  143. v-tippy
  144. content="Fill from Discogs"
  145. >album</i
  146. >
  147. </button>
  148. </p>
  149. </div>
  150. <div class="duration-container">
  151. <label class="label">Duration</label>
  152. <p class="control has-addons">
  153. <input
  154. class="input"
  155. type="text"
  156. placeholder="Enter song duration..."
  157. v-model.number="song.duration"
  158. @keyup.shift.enter="fillDuration()"
  159. />
  160. <button
  161. class="button duration-fill-button"
  162. @click="fillDuration()"
  163. >
  164. <i
  165. class="material-icons"
  166. v-tippy
  167. content="Sync duration with YouTube"
  168. >sync</i
  169. >
  170. </button>
  171. </p>
  172. </div>
  173. <div class="skip-duration-container">
  174. <label class="label">Skip duration</label>
  175. <p class="control">
  176. <input
  177. class="input"
  178. type="text"
  179. placeholder="Enter skip duration..."
  180. v-model.number="song.skipDuration"
  181. />
  182. </p>
  183. </div>
  184. </div>
  185. <div class="control is-grouped">
  186. <div class="album-art-container">
  187. <label class="label">Album art</label>
  188. <p class="control has-addons">
  189. <input
  190. class="input"
  191. type="text"
  192. v-model="song.thumbnail"
  193. placeholder="Enter link to album art..."
  194. @keyup.shift.enter="
  195. getAlbumData('albumArt')
  196. "
  197. />
  198. <button
  199. class="button album-get-button"
  200. @click="getAlbumData('albumArt')"
  201. >
  202. <i
  203. class="material-icons"
  204. v-tippy
  205. content="Fill from Discogs"
  206. >album</i
  207. >
  208. </button>
  209. </p>
  210. </div>
  211. </div>
  212. <div class="control is-grouped">
  213. <div class="artists-container">
  214. <label class="label">Artists</label>
  215. <p class="control has-addons">
  216. <input
  217. class="input"
  218. type="text"
  219. ref="new-artist"
  220. v-model="artistInputValue"
  221. placeholder="Add artist..."
  222. @blur="blurArtistInput()"
  223. @focus="focusArtistInput()"
  224. @keydown="keydownArtistInput()"
  225. @keyup.exact.enter="addTag('artists')"
  226. @keyup.shift.enter="
  227. getAlbumData('artists')
  228. "
  229. />
  230. <button
  231. class="button album-get-button"
  232. @click="getAlbumData('artists')"
  233. >
  234. <i
  235. class="material-icons"
  236. v-tippy
  237. content="Fill from Discogs"
  238. >album</i
  239. >
  240. </button>
  241. <button
  242. class="button is-info add-button"
  243. @click="addTag('artists')"
  244. >
  245. <i class="material-icons">add</i>
  246. </button>
  247. </p>
  248. <div
  249. class="autosuggest-container"
  250. v-if="
  251. (artistInputFocussed ||
  252. artistAutosuggestContainerFocussed) &&
  253. artistAutosuggestItems.length > 0
  254. "
  255. @mouseover="focusArtistContainer()"
  256. @mouseleave="blurArtistContainer()"
  257. >
  258. <span
  259. class="autosuggest-item"
  260. tabindex="0"
  261. @click="addTag('artists', item)"
  262. v-for="item in artistAutosuggestItems"
  263. :key="item"
  264. >{{ item }}</span
  265. >
  266. </div>
  267. <div class="list-container">
  268. <div
  269. class="list-item"
  270. v-for="artist in song.artists"
  271. :key="artist"
  272. >
  273. <div
  274. class="list-item-circle"
  275. @click="
  276. removeTag('artists', artist)
  277. "
  278. >
  279. <i class="material-icons">close</i>
  280. </div>
  281. <p>{{ artist }}</p>
  282. </div>
  283. </div>
  284. </div>
  285. <div class="genres-container">
  286. <label class="label">
  287. <span>Genres</span>
  288. <i
  289. class="material-icons"
  290. @click="toggleGenreHelper"
  291. @dblclick="resetGenreHelper"
  292. v-tippy
  293. content="View list of genres"
  294. >info</i
  295. >
  296. </label>
  297. <p class="control has-addons">
  298. <input
  299. class="input"
  300. type="text"
  301. ref="new-genre"
  302. v-model="genreInputValue"
  303. placeholder="Add genre..."
  304. @blur="blurGenreInput()"
  305. @focus="focusGenreInput()"
  306. @keydown="keydownGenreInput()"
  307. @keyup.exact.enter="addTag('genres')"
  308. @keyup.shift.enter="
  309. getAlbumData('genres')
  310. "
  311. />
  312. <button
  313. class="button album-get-button"
  314. @click="getAlbumData('genres')"
  315. >
  316. <i
  317. class="material-icons"
  318. v-tippy
  319. content="Fill from Discogs"
  320. >album</i
  321. >
  322. </button>
  323. <button
  324. class="button is-info add-button"
  325. @click="addTag('genres')"
  326. >
  327. <i class="material-icons">add</i>
  328. </button>
  329. </p>
  330. <div
  331. class="autosuggest-container"
  332. v-if="
  333. (genreInputFocussed ||
  334. genreAutosuggestContainerFocussed) &&
  335. genreAutosuggestItems.length > 0
  336. "
  337. @mouseover="focusGenreContainer()"
  338. @mouseleave="blurGenreContainer()"
  339. >
  340. <span
  341. class="autosuggest-item"
  342. @click="addTag('genres', item)"
  343. v-for="item in genreAutosuggestItems"
  344. :key="item"
  345. >{{ item }}</span
  346. >
  347. </div>
  348. <div class="list-container">
  349. <div
  350. class="list-item"
  351. v-for="genre in song.genres"
  352. :key="genre"
  353. >
  354. <div
  355. class="list-item-circle"
  356. @click="removeTag('genres', genre)"
  357. >
  358. <i class="material-icons">close</i>
  359. </div>
  360. <p>{{ genre }}</p>
  361. </div>
  362. </div>
  363. </div>
  364. <div class="youtube-id-container">
  365. <label class="label">YouTube ID</label>
  366. <p class="control">
  367. <input
  368. class="input"
  369. type="text"
  370. placeholder="Enter YouTube ID..."
  371. v-model="song.youtubeId"
  372. />
  373. </p>
  374. </div>
  375. </div>
  376. </div>
  377. </div>
  378. <div class="right-section" v-if="songDataLoaded">
  379. <div id="tabs-container">
  380. <div id="tab-selection">
  381. <button
  382. class="button is-default"
  383. :class="{ selected: tab === 'discogs' }"
  384. ref="discogs-tab"
  385. @click="showTab('discogs')"
  386. >
  387. Discogs
  388. </button>
  389. <button
  390. class="button is-default"
  391. :class="{ selected: tab === 'reports' }"
  392. ref="reports-tab"
  393. @click="showTab('reports')"
  394. >
  395. Reports ({{ reports.length }})
  396. </button>
  397. <button
  398. class="button is-default"
  399. :class="{ selected: tab === 'youtube' }"
  400. ref="youtube-tab"
  401. @click="showTab('youtube')"
  402. >
  403. YouTube
  404. </button>
  405. <button
  406. class="button is-default"
  407. :class="{ selected: tab === 'musare-songs' }"
  408. ref="musare-songs-tab"
  409. @click="showTab('musare-songs')"
  410. >
  411. Songs
  412. </button>
  413. </div>
  414. <discogs class="tab" v-show="tab === 'discogs'" />
  415. <reports class="tab" v-show="tab === 'reports'" />
  416. <youtube class="tab" v-show="tab === 'youtube'" />
  417. <musare-songs
  418. class="tab"
  419. v-show="tab === 'musare-songs'"
  420. />
  421. </div>
  422. </div>
  423. </template>
  424. <template #footer>
  425. <div>
  426. <save-button
  427. ref="saveButton"
  428. @clicked="save(song, false, false)"
  429. />
  430. <save-button
  431. ref="saveAndCloseButton"
  432. default-message="Save and close"
  433. @clicked="save(song, false, true)"
  434. />
  435. <save-button
  436. ref="saveVerifyAndCloseButton"
  437. default-message="Save, verify and close"
  438. @click="save(song, true, true)"
  439. />
  440. <button
  441. class="button is-danger"
  442. @click="stopEditingSongs()"
  443. v-if="modals.importAlbum && editingSongs"
  444. >
  445. Stop editing songs
  446. </button>
  447. <div class="right">
  448. <button
  449. v-if="song.status !== 'verified'"
  450. class="button is-success"
  451. @click="verify(song._id)"
  452. content="Verify Song"
  453. v-tippy
  454. >
  455. <i class="material-icons">check_circle</i>
  456. </button>
  457. <confirm
  458. v-if="song.status === 'verified'"
  459. placement="left"
  460. @confirm="unverify(song._id)"
  461. >
  462. <button
  463. class="button is-danger"
  464. content="Unverify Song"
  465. v-tippy
  466. >
  467. <i class="material-icons">cancel</i>
  468. </button>
  469. </confirm>
  470. <confirm
  471. v-if="song.status !== 'hidden'"
  472. placement="left"
  473. @confirm="hide(song._id)"
  474. >
  475. <button
  476. class="button is-danger"
  477. content="Hide Song"
  478. v-tippy
  479. >
  480. <i class="material-icons">visibility_off</i>
  481. </button>
  482. </confirm>
  483. <button
  484. v-if="song.status === 'hidden'"
  485. class="button is-success"
  486. @click="unhide(song._id)"
  487. content="Unhide Song"
  488. v-tippy
  489. >
  490. <i class="material-icons">visibility</i>
  491. </button>
  492. <!-- <confirm placement="left" @confirm="remove(song._id)">
  493. <button
  494. class="button is-danger"
  495. content="Remove Song"
  496. v-tippy
  497. >
  498. <i class="material-icons">delete</i>
  499. </button>
  500. </confirm> -->
  501. </div>
  502. </div>
  503. </template>
  504. </modal>
  505. <floating-box id="genreHelper" ref="genreHelper" :column="false">
  506. <template #body>
  507. <span>Blues</span><span>Country</span><span>Disco</span
  508. ><span>Funk</span><span>Hip-Hop</span><span>Jazz</span
  509. ><span>Metal</span><span>Oldies</span><span>Other</span
  510. ><span>Pop</span><span>Rap</span><span>Reggae</span
  511. ><span>Rock</span><span>Techno</span><span>Trance</span
  512. ><span>Classical</span><span>Instrumental</span
  513. ><span>House</span><span>Electronic</span
  514. ><span>Christian Rap</span><span>Lo-Fi</span><span>Musical</span
  515. ><span>Rock 'n' Roll</span><span>Opera</span
  516. ><span>Drum & Bass</span><span>Club-House</span
  517. ><span>Indie</span><span>Heavy Metal</span
  518. ><span>Christian rock</span><span>Dubstep</span>
  519. </template>
  520. </floating-box>
  521. </div>
  522. </template>
  523. <script>
  524. import { mapState, mapGetters, mapActions } from "vuex";
  525. import Toast from "toasters";
  526. import aw from "@/aw";
  527. import ws from "@/ws";
  528. import validation from "@/validation";
  529. import keyboardShortcuts from "@/keyboardShortcuts";
  530. import Confirm from "@/components/Confirm.vue";
  531. import Modal from "../../Modal.vue";
  532. import FloatingBox from "../../FloatingBox.vue";
  533. import SaveButton from "../../SaveButton.vue";
  534. import Discogs from "./Tabs/Discogs.vue";
  535. import Reports from "./Tabs/Reports.vue";
  536. import Youtube from "./Tabs/Youtube.vue";
  537. import MusareSongs from "./Tabs/Songs.vue";
  538. export default {
  539. components: {
  540. Modal,
  541. FloatingBox,
  542. SaveButton,
  543. Confirm,
  544. Discogs,
  545. Reports,
  546. Youtube,
  547. MusareSongs
  548. },
  549. props: {
  550. youtubeId: { type: String, default: null },
  551. songId: { type: String, default: null },
  552. discogsAlbum: { type: Object, default: null },
  553. sector: { type: String, default: "admin" }
  554. },
  555. data() {
  556. return {
  557. songDataLoaded: false,
  558. youtubeError: false,
  559. youtubeErrorMessage: "",
  560. focusedElementBefore: null,
  561. youtubeVideoDuration: "0.000",
  562. youtubeVideoCurrentTime: 0,
  563. youtubeVideoNote: "",
  564. useHTTPS: false,
  565. muted: false,
  566. volumeSliderValue: 0,
  567. skipToLast10SecsPressed: false,
  568. artistInputValue: "",
  569. genreInputValue: "",
  570. artistInputFocussed: false,
  571. genreInputFocussed: false,
  572. genreAutosuggestContainerFocussed: false,
  573. artistAutosuggestContainerFocussed: false,
  574. keydownArtistInputTimeout: 0,
  575. keydownGenreInputTimeout: 0,
  576. artistAutosuggestItems: [],
  577. genreAutosuggestItems: [],
  578. activityWatchVideoDataInterval: null,
  579. activityWatchVideoLastStatus: "",
  580. activityWatchVideoLastStartDuration: "",
  581. genres: [
  582. "Blues",
  583. "Country",
  584. "Disco",
  585. "Funk",
  586. "Hip-Hop",
  587. "Jazz",
  588. "Metal",
  589. "Oldies",
  590. "Other",
  591. "Pop",
  592. "Rap",
  593. "Reggae",
  594. "Rock",
  595. "Techno",
  596. "Trance",
  597. "Classical",
  598. "Instrumental",
  599. "House",
  600. "Electronic",
  601. "Christian Rap",
  602. "Lo-Fi",
  603. "Musical",
  604. "Rock 'n' Roll",
  605. "Opera",
  606. "Drum & Bass",
  607. "Club-House",
  608. "Indie",
  609. "Heavy Metal",
  610. "Christian rock",
  611. "Dubstep"
  612. ]
  613. };
  614. },
  615. computed: {
  616. ...mapState("modals/editSong", {
  617. tab: state => state.tab,
  618. video: state => state.video,
  619. song: state => state.song,
  620. originalSong: state => state.originalSong,
  621. reports: state => state.reports
  622. }),
  623. ...mapState("modals/importAlbum", {
  624. editingSongs: state => state.editingSongs
  625. }),
  626. ...mapState("modalVisibility", {
  627. modals: state => state.modals
  628. }),
  629. ...mapGetters({
  630. socket: "websockets/getSocket"
  631. })
  632. },
  633. watch: {
  634. /* eslint-disable */
  635. "song.duration": function () {
  636. this.drawCanvas();
  637. },
  638. "song.skipDuration": function () {
  639. this.drawCanvas();
  640. }
  641. /* eslint-enable */
  642. },
  643. async mounted() {
  644. this.activityWatchVideoDataInterval = setInterval(() => {
  645. this.sendActivityWatchVideoData();
  646. }, 1000);
  647. this.useHTTPS = await lofig.get("cookie.secure");
  648. ws.onConnect(this.init);
  649. let volume = parseFloat(localStorage.getItem("volume"));
  650. volume =
  651. typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  652. localStorage.setItem("volume", volume);
  653. this.volumeSliderValue = volume * 100;
  654. this.socket.on(
  655. "event:admin.song.updated",
  656. res => {
  657. if (res.data.song._id === this.song._id)
  658. this.song.status = res.data.song.status;
  659. },
  660. { modal: "editSong" }
  661. );
  662. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  663. keyCode: 101,
  664. preventDefault: true,
  665. handler: () => {
  666. if (this.video.paused) this.play();
  667. else this.settings("pause");
  668. }
  669. });
  670. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  671. keyCode: 101,
  672. ctrl: true,
  673. preventDefault: true,
  674. handler: () => {
  675. this.settings("stop");
  676. }
  677. });
  678. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  679. keyCode: 102,
  680. preventDefault: true,
  681. handler: () => {
  682. this.settings("skipToLast10Secs");
  683. }
  684. });
  685. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  686. keyCode: 98,
  687. preventDefault: true,
  688. handler: () => {
  689. this.volumeSliderValue = Math.max(
  690. 0,
  691. this.volumeSliderValue - 1000
  692. );
  693. this.changeVolume();
  694. }
  695. });
  696. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  697. keyCode: 98,
  698. ctrl: true,
  699. preventDefault: true,
  700. handler: () => {
  701. this.volumeSliderValue = Math.max(
  702. 0,
  703. this.volumeSliderValue - 100
  704. );
  705. this.changeVolume();
  706. }
  707. });
  708. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  709. keyCode: 104,
  710. preventDefault: true,
  711. handler: () => {
  712. this.volumeSliderValue = Math.min(
  713. 10000,
  714. this.volumeSliderValue + 1000
  715. );
  716. this.changeVolume();
  717. }
  718. });
  719. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  720. keyCode: 104,
  721. ctrl: true,
  722. preventDefault: true,
  723. handler: () => {
  724. this.volumeSliderValue = Math.min(
  725. 10000,
  726. this.volumeSliderValue + 100
  727. );
  728. this.changeVolume();
  729. }
  730. });
  731. keyboardShortcuts.registerShortcut("editSong.save", {
  732. keyCode: 83,
  733. ctrl: true,
  734. preventDefault: true,
  735. handler: () => {
  736. this.save(this.song, false, false);
  737. }
  738. });
  739. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  740. keyCode: 83,
  741. ctrl: true,
  742. alt: true,
  743. preventDefault: true,
  744. handler: () => {
  745. this.save(this.song, true);
  746. }
  747. });
  748. // TODO
  749. keyboardShortcuts.registerShortcut("editSong.saveVerifyClose", {
  750. keyCode: 86,
  751. ctrl: true,
  752. alt: true,
  753. preventDefault: true,
  754. handler: () => {
  755. // alert("not implemented yet");
  756. }
  757. });
  758. keyboardShortcuts.registerShortcut("editSong.close", {
  759. keyCode: 115,
  760. preventDefault: true,
  761. handler: () => {
  762. this.closeModal("editSong");
  763. setTimeout(() => {
  764. window.focusedElementBefore.focus();
  765. }, 500);
  766. }
  767. });
  768. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  769. keyCode: 36,
  770. preventDefault: true,
  771. handler: () => {
  772. this.$refs["title-input"].focus();
  773. }
  774. });
  775. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  776. keyCode: 68,
  777. alt: true,
  778. ctrl: true,
  779. preventDefault: true,
  780. handler: () => {
  781. this.getAlbumData("title");
  782. this.getAlbumData("albumArt");
  783. this.getAlbumData("artists");
  784. this.getAlbumData("genres");
  785. }
  786. });
  787. /*
  788. editSong.pauseResume - Num 5 - Pause/resume song
  789. editSong.stopVideo - Ctrl - Num 5 - Stop
  790. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  791. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  792. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  793. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  794. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  795. editSong.focusTitle - Home - Focus the title input
  796. editSong.focusDicogs - End - Focus the discogs input
  797. editSong.save - Ctrl - S - Saves song
  798. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  799. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  800. editSong.close - F4 - Closes modal without saving
  801. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  802. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  803. */
  804. },
  805. beforeUnmount() {
  806. this.video.player.stopVideo();
  807. this.playerReady = false;
  808. clearInterval(this.interval);
  809. clearInterval(this.activityWatchVideoDataInterval);
  810. this.socket.dispatch("apis.leaveRoom", `edit-song.${this.song._id}`);
  811. const shortcutNames = [
  812. "editSong.pauseResume",
  813. "editSong.stopVideo",
  814. "editSong.skipToLast10Secs",
  815. "editSong.lowerVolumeLarge",
  816. "editSong.lowerVolumeSmall",
  817. "editSong.increaseVolumeLarge",
  818. "editSong.increaseVolumeSmall",
  819. "editSong.focusTitle",
  820. "editSong.focusDicogs",
  821. "editSong.save",
  822. "editSong.saveClose",
  823. "editSong.saveVerifyClose",
  824. "editSong.close",
  825. "editSong.useAllDiscogs"
  826. ];
  827. shortcutNames.forEach(shortcutName => {
  828. keyboardShortcuts.unregisterShortcut(shortcutName);
  829. });
  830. },
  831. methods: {
  832. init() {
  833. this.socket.dispatch(
  834. `songs.getSongFromSongId`,
  835. this.song._id,
  836. res => {
  837. if (res.status === "success") {
  838. let { song } = res.data;
  839. if (this.song.prefill)
  840. song = Object.assign(song, this.song.prefill);
  841. if (this.song.discogs)
  842. song = {
  843. ...song,
  844. discogs: this.song.discogs
  845. };
  846. this.editSong(song);
  847. this.songDataLoaded = true;
  848. this.socket.dispatch(
  849. "apis.joinRoom",
  850. `edit-song.${this.song._id}`
  851. );
  852. this.interval = setInterval(() => {
  853. if (
  854. this.song.duration !== -1 &&
  855. this.video.paused === false &&
  856. this.playerReady &&
  857. (this.video.player.getCurrentTime() -
  858. this.song.skipDuration >
  859. this.song.duration ||
  860. (this.video.player.getCurrentTime() > 0 &&
  861. this.video.player.getCurrentTime() >=
  862. this.video.player.getDuration()))
  863. ) {
  864. this.video.paused = true;
  865. this.video.player.stopVideo();
  866. this.drawCanvas();
  867. }
  868. if (this.playerReady) {
  869. this.youtubeVideoCurrentTime = this.video.player
  870. .getCurrentTime()
  871. .toFixed(3);
  872. }
  873. if (this.video.paused === false) this.drawCanvas();
  874. }, 200);
  875. if (window.YT && window.YT.Player) {
  876. this.video.player = new window.YT.Player(
  877. "editSongPlayer",
  878. {
  879. height: 298,
  880. width: 530,
  881. videoId: this.song.youtubeId,
  882. host: "https://www.youtube-nocookie.com",
  883. playerVars: {
  884. controls: 0,
  885. iv_load_policy: 3,
  886. rel: 0,
  887. showinfo: 0,
  888. autoplay: 0
  889. },
  890. startSeconds: this.song.skipDuration,
  891. events: {
  892. onReady: () => {
  893. let volume = parseInt(
  894. localStorage.getItem("volume")
  895. );
  896. volume =
  897. typeof volume === "number"
  898. ? volume
  899. : 20;
  900. this.video.player.setVolume(volume);
  901. if (volume > 0)
  902. this.video.player.unMute();
  903. const duration =
  904. this.video.player.getDuration();
  905. this.youtubeVideoDuration =
  906. duration.toFixed(3);
  907. this.youtubeVideoNote = "(~)";
  908. this.playerReady = true;
  909. this.drawCanvas();
  910. },
  911. onStateChange: event => {
  912. this.drawCanvas();
  913. let skipToLast10SecsPressed = false;
  914. if (
  915. event.data === 1 &&
  916. this.skipToLast10SecsPressed
  917. ) {
  918. this.skipToLast10SecsPressed = false;
  919. skipToLast10SecsPressed = true;
  920. }
  921. if (
  922. event.data === 1 &&
  923. !skipToLast10SecsPressed
  924. ) {
  925. this.video.paused = false;
  926. let youtubeDuration =
  927. this.video.player.getDuration();
  928. const newYoutubeVideoDuration =
  929. youtubeDuration.toFixed(3);
  930. const songDurationNumber =
  931. Number(this.song.duration);
  932. const songDurationNumber2 =
  933. Number(this.song.duration) +
  934. 1;
  935. const songDurationNumber3 =
  936. Number(this.song.duration) -
  937. 1;
  938. const fixedSongDuration =
  939. songDurationNumber.toFixed(
  940. 3
  941. );
  942. const fixedSongDuration2 =
  943. songDurationNumber2.toFixed(
  944. 3
  945. );
  946. const fixedSongDuration3 =
  947. songDurationNumber3.toFixed(
  948. 3
  949. );
  950. if (
  951. this
  952. .youtubeVideoDuration !==
  953. newYoutubeVideoDuration &&
  954. (fixedSongDuration ===
  955. this
  956. .youtubeVideoDuration ||
  957. fixedSongDuration2 ===
  958. this
  959. .youtubeVideoDuration ||
  960. fixedSongDuration3 ===
  961. this
  962. .youtubeVideoDuration)
  963. )
  964. this.song.duration =
  965. newYoutubeVideoDuration;
  966. this.youtubeVideoDuration =
  967. newYoutubeVideoDuration;
  968. this.youtubeVideoNote = "";
  969. if (this.song.duration === -1)
  970. this.song.duration =
  971. youtubeDuration;
  972. youtubeDuration -=
  973. this.song.skipDuration;
  974. if (
  975. this.song.duration >
  976. youtubeDuration + 1
  977. ) {
  978. this.video.player.stopVideo();
  979. this.video.paused = true;
  980. return new Toast(
  981. "Video can't play. Specified duration is bigger than the YouTube song duration."
  982. );
  983. }
  984. if (this.song.duration <= 0) {
  985. this.video.player.stopVideo();
  986. this.video.paused = true;
  987. return new Toast(
  988. "Video can't play. Specified duration has to be more than 0 seconds."
  989. );
  990. }
  991. if (
  992. this.video.player.getCurrentTime() <
  993. this.song.skipDuration
  994. ) {
  995. return this.video.player.seekTo(
  996. this.song.skipDuration
  997. );
  998. }
  999. } else if (event.data === 2) {
  1000. this.video.paused = true;
  1001. }
  1002. return false;
  1003. }
  1004. }
  1005. }
  1006. );
  1007. } else {
  1008. this.youtubeError = true;
  1009. this.youtubeErrorMessage =
  1010. "Player could not be loaded.";
  1011. }
  1012. } else {
  1013. new Toast("Song with that ID not found");
  1014. this.closeModal("editSong");
  1015. }
  1016. }
  1017. );
  1018. this.socket.dispatch(
  1019. "reports.getReportsForSong",
  1020. this.song._id,
  1021. res => {
  1022. this.updateReports(res.data.reports);
  1023. }
  1024. );
  1025. },
  1026. stopEditingSongs() {
  1027. this.updateEditingSongs(false);
  1028. this.closeModal("editSong");
  1029. },
  1030. importAlbum(result) {
  1031. this.selectDiscogsAlbum(result);
  1032. this.openModal("importAlbum");
  1033. this.closeModal("editSong");
  1034. },
  1035. save(songToCopy, verify, close) {
  1036. const song = JSON.parse(JSON.stringify(songToCopy));
  1037. let saveButtonRef = this.$refs.saveButton;
  1038. if (close && !verify) saveButtonRef = this.$refs.saveAndCloseButton;
  1039. else if (close && verify)
  1040. saveButtonRef = this.$refs.saveVerifyAndCloseButton;
  1041. if (!this.youtubeError && this.youtubeVideoDuration === "0.000") {
  1042. saveButtonRef.handleFailedSave();
  1043. return new Toast("The video appears to not be working.");
  1044. }
  1045. if (!song.title) {
  1046. saveButtonRef.handleFailedSave();
  1047. return new Toast("Please fill in all fields");
  1048. }
  1049. if (!song.thumbnail) {
  1050. saveButtonRef.handleFailedSave();
  1051. return new Toast("Please fill in all fields");
  1052. }
  1053. // const thumbnailHeight = this.$refs.thumbnailElement.naturalHeight;
  1054. // const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  1055. // if (thumbnailHeight < 80 || thumbnailWidth < 80) {
  1056. // saveButtonRef.handleFailedSave();
  1057. // return new Toast(
  1058. // "Thumbnail width and height must be at least 80px."
  1059. // );
  1060. // }
  1061. // if (thumbnailHeight > 4000 || thumbnailWidth > 4000) {
  1062. // saveButtonRef.handleFailedSave();
  1063. // return new Toast(
  1064. // "Thumbnail width and height must be less than 4000px."
  1065. // );
  1066. // }
  1067. // if (thumbnailHeight - thumbnailWidth > 5) {
  1068. // saveButtonRef.handleFailedSave();
  1069. // return new Toast("Thumbnail cannot be taller than it is wide.");
  1070. // }
  1071. // Youtube Id
  1072. if (
  1073. this.youtubeError &&
  1074. this.originalSong.youtubeId !== song.youtubeId
  1075. ) {
  1076. saveButtonRef.handleFailedSave();
  1077. return new Toast(
  1078. "You're not allowed to change the YouTube id while the player is not working"
  1079. );
  1080. }
  1081. // Duration
  1082. if (
  1083. Number(song.skipDuration) + Number(song.duration) >
  1084. this.youtubeVideoDuration &&
  1085. (!this.youtubeError ||
  1086. this.originalSong.duration !== song.duration)
  1087. ) {
  1088. saveButtonRef.handleFailedSave();
  1089. return new Toast(
  1090. "Duration can't be higher than the length of the video"
  1091. );
  1092. }
  1093. // Title
  1094. if (!validation.isLength(song.title, 1, 100)) {
  1095. saveButtonRef.handleFailedSave();
  1096. return new Toast(
  1097. "Title must have between 1 and 100 characters."
  1098. );
  1099. }
  1100. // Artists
  1101. if (song.artists.length < 1 || song.artists.length > 10) {
  1102. saveButtonRef.handleFailedSave();
  1103. return new Toast(
  1104. "Invalid artists. You must have at least 1 artist and a maximum of 10 artists."
  1105. );
  1106. }
  1107. let error;
  1108. song.artists.forEach(artist => {
  1109. if (!validation.isLength(artist, 1, 64)) {
  1110. error = "Artist must have between 1 and 64 characters.";
  1111. return error;
  1112. }
  1113. if (artist === "NONE") {
  1114. error =
  1115. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  1116. return error;
  1117. }
  1118. return false;
  1119. });
  1120. if (error) {
  1121. saveButtonRef.handleFailedSave();
  1122. return new Toast(error);
  1123. }
  1124. // Genres
  1125. error = undefined;
  1126. song.genres.forEach(genre => {
  1127. if (!validation.isLength(genre, 1, 32)) {
  1128. error = "Genre must have between 1 and 32 characters.";
  1129. return error;
  1130. }
  1131. if (!validation.regex.ascii.test(genre)) {
  1132. error =
  1133. "Invalid genre format. Only ascii characters are allowed.";
  1134. return error;
  1135. }
  1136. return false;
  1137. });
  1138. if (song.genres.length < 1 || song.genres.length > 16)
  1139. error = "You must have between 1 and 16 genres.";
  1140. if (error) {
  1141. saveButtonRef.handleFailedSave();
  1142. return new Toast(error);
  1143. }
  1144. // Thumbnail
  1145. if (!validation.isLength(song.thumbnail, 1, 256)) {
  1146. saveButtonRef.handleFailedSave();
  1147. return new Toast(
  1148. "Thumbnail must have between 8 and 256 characters."
  1149. );
  1150. }
  1151. if (this.useHTTPS && song.thumbnail.indexOf("https://") !== 0) {
  1152. saveButtonRef.handleFailedSave();
  1153. return new Toast('Thumbnail must start with "https://".');
  1154. }
  1155. if (
  1156. !this.useHTTPS &&
  1157. song.thumbnail.indexOf("http://") !== 0 &&
  1158. song.thumbnail.indexOf("https://") !== 0
  1159. ) {
  1160. saveButtonRef.handleFailedSave();
  1161. return new Toast('Thumbnail must start with "http://".');
  1162. }
  1163. saveButtonRef.status = "disabled";
  1164. return this.socket.dispatch(`songs.update`, song._id, song, res => {
  1165. new Toast(res.message);
  1166. if (res.status === "success")
  1167. saveButtonRef.handleSuccessfulSave();
  1168. else saveButtonRef.handleFailedSave();
  1169. if (verify) this.verify(this.song._id);
  1170. if (close) this.closeModal("editSong");
  1171. });
  1172. },
  1173. getAlbumData(type) {
  1174. if (!this.song.discogs) return;
  1175. if (type === "title")
  1176. this.updateSongField({
  1177. field: "title",
  1178. value: this.song.discogs.track.title
  1179. });
  1180. if (type === "albumArt")
  1181. this.updateSongField({
  1182. field: "thumbnail",
  1183. value: this.song.discogs.album.albumArt
  1184. });
  1185. if (type === "genres")
  1186. this.updateSongField({
  1187. field: "genres",
  1188. value: JSON.parse(
  1189. JSON.stringify(this.song.discogs.album.genres)
  1190. )
  1191. });
  1192. if (type === "artists")
  1193. this.updateSongField({
  1194. field: "artists",
  1195. value: JSON.parse(
  1196. JSON.stringify(this.song.discogs.album.artists)
  1197. )
  1198. });
  1199. },
  1200. fillDuration() {
  1201. this.song.duration =
  1202. this.youtubeVideoDuration - this.song.skipDuration;
  1203. },
  1204. blurArtistInput() {
  1205. this.artistInputFocussed = false;
  1206. },
  1207. focusArtistInput() {
  1208. this.artistInputFocussed = true;
  1209. },
  1210. blurArtistContainer() {
  1211. this.artistAutosuggestContainerFocussed = false;
  1212. },
  1213. focusArtistContainer() {
  1214. this.artistAutosuggestContainerFocussed = true;
  1215. },
  1216. keydownArtistInput() {
  1217. clearTimeout(this.keydownArtistInputTimeout);
  1218. this.keydownArtistInputTimeout = setTimeout(() => {
  1219. // Do things here to query the artist
  1220. }, 1000);
  1221. },
  1222. blurGenreInput() {
  1223. this.genreInputFocussed = false;
  1224. },
  1225. focusGenreInput() {
  1226. this.genreInputFocussed = true;
  1227. },
  1228. blurGenreContainer() {
  1229. this.genreAutosuggestContainerFocussed = false;
  1230. },
  1231. focusGenreContainer() {
  1232. this.genreAutosuggestContainerFocussed = true;
  1233. },
  1234. keydownGenreInput() {
  1235. clearTimeout(this.keydownGenreInputTimeout);
  1236. this.keydownGenreInputTimeout = setTimeout(() => {
  1237. if (this.genreInputValue.length > 1) {
  1238. this.genreAutosuggestItems = this.genres.filter(genre =>
  1239. genre
  1240. .toLowerCase()
  1241. .startsWith(this.genreInputValue.toLowerCase())
  1242. );
  1243. } else this.genreAutosuggestItems = [];
  1244. }, 1000);
  1245. },
  1246. settings(type) {
  1247. switch (type) {
  1248. default:
  1249. break;
  1250. case "stop":
  1251. this.stopVideo();
  1252. this.pauseVideo(true);
  1253. break;
  1254. case "pause":
  1255. this.pauseVideo(true);
  1256. break;
  1257. case "play":
  1258. this.pauseVideo(false);
  1259. break;
  1260. case "skipToLast10Secs":
  1261. this.skipToLast10SecsPressed = true;
  1262. if (this.video.paused) this.pauseVideo(false);
  1263. this.video.player.seekTo(
  1264. this.song.duration - 10 + this.song.skipDuration
  1265. );
  1266. break;
  1267. }
  1268. },
  1269. play() {
  1270. if (
  1271. this.video.player.getVideoData().video_id !==
  1272. this.song.youtubeId
  1273. ) {
  1274. this.song.duration = -1;
  1275. this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
  1276. }
  1277. this.settings("play");
  1278. },
  1279. changeVolume() {
  1280. const volume = this.volumeSliderValue;
  1281. localStorage.setItem("volume", volume / 100);
  1282. this.video.player.setVolume(volume / 100);
  1283. if (volume > 0) {
  1284. this.video.player.unMute();
  1285. this.muted = false;
  1286. }
  1287. },
  1288. toggleMute() {
  1289. const previousVolume = parseFloat(localStorage.getItem("volume"));
  1290. const volume =
  1291. this.video.player.getVolume() * 100 <= 0 ? previousVolume : 0;
  1292. this.muted = !this.muted;
  1293. this.volumeSliderValue = volume * 100;
  1294. this.video.player.setVolume(volume);
  1295. if (!this.muted) localStorage.setItem("volume", volume);
  1296. },
  1297. increaseVolume() {
  1298. const previousVolume = parseInt(localStorage.getItem("volume"));
  1299. let volume = previousVolume + 5;
  1300. this.muted = false;
  1301. if (volume > 100) volume = 100;
  1302. this.volumeSliderValue = volume * 100;
  1303. this.video.player.setVolume(volume);
  1304. localStorage.setItem("volume", volume);
  1305. },
  1306. addTag(type, value) {
  1307. if (type === "genres") {
  1308. const genre = value || this.genreInputValue.trim();
  1309. if (
  1310. this.song.genres
  1311. .map(genre => genre.toLowerCase())
  1312. .indexOf(genre.toLowerCase()) !== -1
  1313. )
  1314. return new Toast("Genre already exists");
  1315. if (genre) {
  1316. this.song.genres.push(genre);
  1317. this.genreInputValue = "";
  1318. this.genreAutosuggestItems = [];
  1319. return false;
  1320. }
  1321. return new Toast("Genre cannot be empty");
  1322. }
  1323. if (type === "artists") {
  1324. const artist = value || this.artistInputValue;
  1325. if (this.song.artists.indexOf(artist) !== -1)
  1326. return new Toast("Artist already exists");
  1327. if (artist !== "") {
  1328. this.song.artists.push(artist);
  1329. this.artistInputValue = "";
  1330. this.artistAutosuggestItems = [];
  1331. return false;
  1332. }
  1333. return new Toast("Artist cannot be empty");
  1334. }
  1335. return false;
  1336. },
  1337. removeTag(type, value) {
  1338. if (type === "genres")
  1339. this.song.genres.splice(this.song.genres.indexOf(value), 1);
  1340. else if (type === "artists")
  1341. this.song.artists.splice(this.song.artists.indexOf(value), 1);
  1342. },
  1343. drawCanvas() {
  1344. const canvasElement = this.$refs.durationCanvas;
  1345. const ctx = canvasElement.getContext("2d");
  1346. const videoDuration = Number(this.youtubeVideoDuration);
  1347. const skipDuration = Number(this.song.skipDuration);
  1348. const duration = Number(this.song.duration);
  1349. const afterDuration = videoDuration - (skipDuration + duration);
  1350. const width = 530;
  1351. const currentTime =
  1352. this.video.player && this.video.player.getCurrentTime
  1353. ? this.video.player.getCurrentTime()
  1354. : 0;
  1355. const widthSkipDuration = (skipDuration / videoDuration) * width;
  1356. const widthDuration = (duration / videoDuration) * width;
  1357. const widthAfterDuration = (afterDuration / videoDuration) * width;
  1358. const widthCurrentTime = (currentTime / videoDuration) * width;
  1359. const skipDurationColor = "#F42003";
  1360. const durationColor = "#03A9F4";
  1361. const afterDurationColor = "#41E841";
  1362. const currentDurationColor = "#3b25e8";
  1363. ctx.fillStyle = skipDurationColor;
  1364. ctx.fillRect(0, 0, widthSkipDuration, 20);
  1365. ctx.fillStyle = durationColor;
  1366. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  1367. ctx.fillStyle = afterDurationColor;
  1368. ctx.fillRect(
  1369. widthSkipDuration + widthDuration,
  1370. 0,
  1371. widthAfterDuration,
  1372. 20
  1373. );
  1374. ctx.fillStyle = currentDurationColor;
  1375. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  1376. },
  1377. toggleGenreHelper() {
  1378. this.$refs.genreHelper.toggleBox();
  1379. },
  1380. resetGenreHelper() {
  1381. this.$refs.genreHelper.resetBox();
  1382. },
  1383. sendActivityWatchVideoData() {
  1384. if (!this.video.paused) {
  1385. if (this.activityWatchVideoLastStatus !== "playing") {
  1386. this.activityWatchVideoLastStatus = "playing";
  1387. if (
  1388. this.song.skipDuration > 0 &&
  1389. parseFloat(this.youtubeVideoCurrentTime) === 0
  1390. ) {
  1391. this.activityWatchVideoLastStartDuration = Math.floor(
  1392. this.song.skipDuration +
  1393. parseFloat(this.youtubeVideoCurrentTime)
  1394. );
  1395. } else {
  1396. this.activityWatchVideoLastStartDuration = Math.floor(
  1397. parseFloat(this.youtubeVideoCurrentTime)
  1398. );
  1399. }
  1400. }
  1401. const videoData = {
  1402. title: this.song.title,
  1403. artists: this.song.artists
  1404. ? this.song.artists.join(", ")
  1405. : null,
  1406. youtubeId: this.song.youtubeId,
  1407. muted: this.muted,
  1408. volume: this.volumeSliderValue / 100,
  1409. startedDuration:
  1410. this.activityWatchVideoLastStartDuration <= 0
  1411. ? 0
  1412. : this.activityWatchVideoLastStartDuration,
  1413. source: `editSong#${this.song.youtubeId}`,
  1414. hostname: window.location.hostname
  1415. };
  1416. aw.sendVideoData(videoData);
  1417. } else {
  1418. this.activityWatchVideoLastStatus = "not_playing";
  1419. }
  1420. },
  1421. verify(id) {
  1422. this.socket.dispatch("songs.verify", id, res => {
  1423. new Toast(res.message);
  1424. });
  1425. },
  1426. unverify(id) {
  1427. this.socket.dispatch("songs.unverify", id, res => {
  1428. new Toast(res.message);
  1429. });
  1430. },
  1431. hide(id) {
  1432. this.socket.dispatch("songs.hide", id, res => {
  1433. new Toast(res.message);
  1434. });
  1435. },
  1436. unhide(id) {
  1437. this.socket.dispatch("songs.unhide", id, res => {
  1438. new Toast(res.message);
  1439. });
  1440. },
  1441. // remove(id) {
  1442. // this.socket.dispatch("songs.remove", id, res => {
  1443. // new Toast(res.message);
  1444. // });
  1445. // },
  1446. ...mapActions("modals/importAlbum", [
  1447. "selectDiscogsAlbum",
  1448. "updateEditingSongs"
  1449. ]),
  1450. ...mapActions({
  1451. showTab(dispatch, payload) {
  1452. this.$refs[`${payload}-tab`].scrollIntoView({
  1453. block: "nearest"
  1454. });
  1455. return dispatch("modals/editSong/showTab", payload);
  1456. }
  1457. }),
  1458. ...mapActions("modals/editSong", [
  1459. "stopVideo",
  1460. "loadVideoById",
  1461. "pauseVideo",
  1462. "getCurrentTime",
  1463. "editSong",
  1464. "updateSongField",
  1465. "updateReports"
  1466. ]),
  1467. ...mapActions("modalVisibility", ["closeModal", "openModal"])
  1468. }
  1469. };
  1470. </script>
  1471. <style lang="scss" scoped>
  1472. .night-mode {
  1473. .edit-section,
  1474. .player-footer,
  1475. #tabs-container {
  1476. background-color: var(--dark-grey-3) !important;
  1477. border: 0 !important;
  1478. .tab {
  1479. border: 0 !important;
  1480. }
  1481. }
  1482. .autosuggest-container {
  1483. background-color: unset !important;
  1484. }
  1485. .autosuggest-item {
  1486. background-color: var(--dark-grey) !important;
  1487. color: var(--white) !important;
  1488. border-color: var(--dark-grey) !important;
  1489. }
  1490. .autosuggest-item:hover,
  1491. .autosuggest-item:focus {
  1492. background-color: var(--dark-grey-2) !important;
  1493. }
  1494. #tabs-container #tab-selection .button {
  1495. background: var(--dark-grey) !important;
  1496. color: var(--white) !important;
  1497. }
  1498. .left-section {
  1499. .edit-section {
  1500. .album-get-button,
  1501. .duration-fill-button,
  1502. .add-button {
  1503. &:focus,
  1504. &:hover {
  1505. border: none !important;
  1506. }
  1507. }
  1508. }
  1509. }
  1510. }
  1511. .modal-card-body {
  1512. display: flex;
  1513. }
  1514. .left-section {
  1515. flex-basis: unset !important;
  1516. height: 100%;
  1517. display: flex;
  1518. flex-direction: column;
  1519. margin-right: 16px;
  1520. .top-section {
  1521. display: flex;
  1522. .player-section {
  1523. width: 530px;
  1524. display: flex;
  1525. flex-direction: column;
  1526. .player-error {
  1527. height: 318px;
  1528. width: 530px;
  1529. display: block;
  1530. border: 1px rgba(163, 224, 255, 0.75) solid;
  1531. border-radius: 5px 5px 0px 0px;
  1532. display: flex;
  1533. align-items: center;
  1534. * {
  1535. margin: 0;
  1536. flex: 1;
  1537. font-size: 30px;
  1538. text-align: center;
  1539. }
  1540. }
  1541. .player-footer {
  1542. border: 1px solid var(--light-grey-3);
  1543. border-radius: 0px 0px 3px 3px;
  1544. display: flex;
  1545. justify-content: space-between;
  1546. height: 54px;
  1547. padding-left: 10px;
  1548. padding-right: 10px;
  1549. > * {
  1550. width: 33.3%;
  1551. display: flex;
  1552. align-items: center;
  1553. }
  1554. .player-footer-left {
  1555. flex: 1;
  1556. .button {
  1557. width: 75px;
  1558. &:not(:first-of-type) {
  1559. margin-left: 5px;
  1560. }
  1561. }
  1562. }
  1563. .player-footer-center {
  1564. justify-content: center;
  1565. align-items: center;
  1566. flex: 2;
  1567. font-size: 18px;
  1568. font-weight: 400;
  1569. width: 200px;
  1570. margin: 0 5px;
  1571. img {
  1572. height: 21px;
  1573. margin-right: 12px;
  1574. filter: invert(26%) sepia(54%) saturate(6317%)
  1575. hue-rotate(2deg) brightness(92%) contrast(115%);
  1576. }
  1577. }
  1578. .player-footer-right {
  1579. justify-content: right;
  1580. flex: 1;
  1581. #volume-control {
  1582. margin: 3px;
  1583. margin-top: 0;
  1584. display: flex;
  1585. align-items: center;
  1586. cursor: pointer;
  1587. .volume-slider {
  1588. width: 100%;
  1589. padding: 0 15px;
  1590. background: transparent;
  1591. min-width: 100px;
  1592. }
  1593. input[type="range"] {
  1594. -webkit-appearance: none;
  1595. margin: 7.3px 0;
  1596. }
  1597. input[type="range"]:focus {
  1598. outline: none;
  1599. }
  1600. input[type="range"]::-webkit-slider-runnable-track {
  1601. width: 100%;
  1602. height: 5.2px;
  1603. cursor: pointer;
  1604. box-shadow: 0;
  1605. background: var(--light-grey-3);
  1606. border-radius: 0;
  1607. border: 0;
  1608. }
  1609. input[type="range"]::-webkit-slider-thumb {
  1610. box-shadow: 0;
  1611. border: 0;
  1612. height: 19px;
  1613. width: 19px;
  1614. border-radius: 15px;
  1615. background: var(--primary-color);
  1616. cursor: pointer;
  1617. -webkit-appearance: none;
  1618. margin-top: -6.5px;
  1619. }
  1620. input[type="range"]::-moz-range-track {
  1621. width: 100%;
  1622. height: 5.2px;
  1623. cursor: pointer;
  1624. box-shadow: 0;
  1625. background: var(--light-grey-3);
  1626. border-radius: 0;
  1627. border: 0;
  1628. }
  1629. input[type="range"]::-moz-range-thumb {
  1630. box-shadow: 0;
  1631. border: 0;
  1632. height: 19px;
  1633. width: 19px;
  1634. border-radius: 15px;
  1635. background: var(--primary-color);
  1636. cursor: pointer;
  1637. -webkit-appearance: none;
  1638. margin-top: -6.5px;
  1639. }
  1640. input[type="range"]::-ms-track {
  1641. width: 100%;
  1642. height: 5.2px;
  1643. cursor: pointer;
  1644. box-shadow: 0;
  1645. background: var(--light-grey-3);
  1646. border-radius: 1.3px;
  1647. }
  1648. input[type="range"]::-ms-fill-lower {
  1649. background: var(--light-grey-3);
  1650. border: 0;
  1651. border-radius: 0;
  1652. box-shadow: 0;
  1653. }
  1654. input[type="range"]::-ms-fill-upper {
  1655. background: var(--light-grey-3);
  1656. border: 0;
  1657. border-radius: 0;
  1658. box-shadow: 0;
  1659. }
  1660. input[type="range"]::-ms-thumb {
  1661. box-shadow: 0;
  1662. border: 0;
  1663. height: 15px;
  1664. width: 15px;
  1665. border-radius: 15px;
  1666. background: var(--primary-color);
  1667. cursor: pointer;
  1668. -webkit-appearance: none;
  1669. margin-top: 1.5px;
  1670. }
  1671. }
  1672. }
  1673. }
  1674. }
  1675. .thumbnail-preview {
  1676. width: 189px;
  1677. height: 189px;
  1678. margin-left: 16px;
  1679. }
  1680. }
  1681. .edit-section {
  1682. width: 735px;
  1683. border: 1px solid var(--light-grey-3);
  1684. flex: 1;
  1685. margin-top: 16px;
  1686. border-radius: 3px;
  1687. .album-get-button {
  1688. background-color: var(--purple);
  1689. color: var(--white);
  1690. width: 32px;
  1691. text-align: center;
  1692. border-width: 0;
  1693. }
  1694. .duration-fill-button {
  1695. background-color: var(--dark-red);
  1696. color: var(--white);
  1697. width: 32px;
  1698. text-align: center;
  1699. border-width: 0;
  1700. }
  1701. .add-button {
  1702. background-color: var(--primary-color) !important;
  1703. width: 32px;
  1704. i {
  1705. font-size: 32px;
  1706. }
  1707. }
  1708. .album-get-button,
  1709. .duration-fill-button,
  1710. .add-button {
  1711. &:focus,
  1712. &:hover {
  1713. filter: contrast(0.75);
  1714. border: 1px solid var(--black) !important;
  1715. }
  1716. }
  1717. > div {
  1718. margin: 16px !important;
  1719. }
  1720. input {
  1721. width: 100%;
  1722. }
  1723. .title-container {
  1724. width: calc((100% - 32px) / 2);
  1725. }
  1726. .duration-container {
  1727. margin-right: 16px;
  1728. margin-left: 16px;
  1729. width: calc((100% - 32px) / 4);
  1730. }
  1731. .skip-duration-container {
  1732. width: calc((100% - 32px) / 4);
  1733. }
  1734. .album-art-container {
  1735. width: 100%;
  1736. }
  1737. .artists-container {
  1738. width: calc((100% - 32px) / 3);
  1739. position: relative;
  1740. }
  1741. .genres-container {
  1742. width: calc((100% - 32px) / 3);
  1743. margin-left: 16px;
  1744. margin-right: 16px;
  1745. position: relative;
  1746. label {
  1747. display: flex;
  1748. i {
  1749. font-size: 15px;
  1750. align-self: center;
  1751. margin-left: 5px;
  1752. color: var(--primary-color);
  1753. cursor: pointer;
  1754. -webkit-user-select: none;
  1755. -moz-user-select: none;
  1756. -ms-user-select: none;
  1757. user-select: none;
  1758. }
  1759. }
  1760. }
  1761. .youtube-id-container {
  1762. width: calc((100% - 32px) / 3);
  1763. }
  1764. .list-item-circle {
  1765. background-color: var(--primary-color);
  1766. width: 16px;
  1767. height: 16px;
  1768. border-radius: 8px;
  1769. cursor: pointer;
  1770. margin-right: 8px;
  1771. float: left;
  1772. -webkit-touch-callout: none;
  1773. -webkit-user-select: none;
  1774. -khtml-user-select: none;
  1775. -moz-user-select: none;
  1776. -ms-user-select: none;
  1777. user-select: none;
  1778. i {
  1779. color: var(--primary-color);
  1780. font-size: 14px;
  1781. margin-left: 1px;
  1782. position: relative;
  1783. top: -1px;
  1784. }
  1785. }
  1786. .list-item-circle:hover,
  1787. .list-item-circle:focus {
  1788. i {
  1789. color: var(--white);
  1790. }
  1791. }
  1792. .list-item > p {
  1793. line-height: 16px;
  1794. word-wrap: break-word;
  1795. width: calc(100% - 24px);
  1796. left: 24px;
  1797. float: left;
  1798. margin-bottom: 8px;
  1799. }
  1800. .list-item:last-child > p {
  1801. margin-bottom: 0;
  1802. }
  1803. .autosuggest-container {
  1804. position: absolute;
  1805. background: var(--white);
  1806. width: calc(100% + 1px);
  1807. top: 57px;
  1808. z-index: 200;
  1809. overflow: auto;
  1810. max-height: 100%;
  1811. clear: both;
  1812. .autosuggest-item {
  1813. padding: 8px;
  1814. display: block;
  1815. border: 1px solid var(--light-grey-2);
  1816. margin-top: -1px;
  1817. line-height: 16px;
  1818. cursor: pointer;
  1819. -webkit-user-select: none;
  1820. -ms-user-select: none;
  1821. -moz-user-select: none;
  1822. user-select: none;
  1823. }
  1824. .autosuggest-item:hover,
  1825. .autosuggest-item:focus {
  1826. background-color: var(--light-grey);
  1827. }
  1828. .autosuggest-item:first-child {
  1829. border-top: none;
  1830. }
  1831. .autosuggest-item:last-child {
  1832. border-radius: 0 0 3px 3px;
  1833. }
  1834. }
  1835. }
  1836. }
  1837. .right-section {
  1838. flex-basis: unset !important;
  1839. flex-grow: 0 !important;
  1840. display: flex;
  1841. height: 100%;
  1842. #tabs-container {
  1843. width: 376px;
  1844. background-color: var(--light-grey);
  1845. border: 1px rgba(163, 224, 255, 0.75) solid;
  1846. border-radius: 5px;
  1847. overflow: auto;
  1848. #tab-selection {
  1849. display: flex;
  1850. overflow-x: auto;
  1851. .button {
  1852. border-radius: 5px 5px 0 0;
  1853. border: 0;
  1854. text-transform: uppercase;
  1855. font-size: 14px;
  1856. color: var(--dark-grey-3);
  1857. background-color: var(--light-grey-2);
  1858. flex-grow: 1;
  1859. height: 32px;
  1860. &:not(:first-of-type) {
  1861. margin-left: 5px;
  1862. }
  1863. }
  1864. .selected {
  1865. background-color: var(--primary-color) !important;
  1866. color: var(--white) !important;
  1867. font-weight: 600;
  1868. }
  1869. }
  1870. .tab {
  1871. border: 1px solid var(--light-grey-3);
  1872. border-radius: 3px;
  1873. padding: 15px;
  1874. }
  1875. }
  1876. }
  1877. .modal-card-foot .is-primary {
  1878. width: 200px;
  1879. }
  1880. </style>