EditSong.vue 47 KB

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