index.vue 52 KB

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