logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

flash.js (1390B)


  1. import RuffleService from '../../services/ruffle_service/ruffle_service.js'
  2. import { library } from '@fortawesome/fontawesome-svg-core'
  3. import {
  4. faStop,
  5. faExclamationTriangle
  6. } from '@fortawesome/free-solid-svg-icons'
  7. library.add(
  8. faStop,
  9. faExclamationTriangle
  10. )
  11. const Flash = {
  12. props: ['src'],
  13. data () {
  14. return {
  15. player: false, // can be true, "hidden", false. hidden = element exists
  16. loaded: false,
  17. ruffleInstance: null
  18. }
  19. },
  20. methods: {
  21. openPlayer () {
  22. if (this.player) return // prevent double-loading, or re-loading on failure
  23. this.player = 'hidden'
  24. RuffleService.getRuffle().then((ruffle) => {
  25. const player = ruffle.newest().createPlayer()
  26. player.config = {
  27. letterbox: 'on'
  28. }
  29. const container = this.$refs.container
  30. container.appendChild(player)
  31. player.style.width = '100%'
  32. player.style.height = '100%'
  33. player.load(this.src).then(() => {
  34. this.player = true
  35. }).catch((e) => {
  36. console.error('Error loading ruffle', e)
  37. this.player = 'error'
  38. })
  39. this.ruffleInstance = player
  40. this.$emit('playerOpened')
  41. })
  42. },
  43. closePlayer () {
  44. this.ruffleInstance && this.ruffleInstance.remove()
  45. this.player = false
  46. this.$emit('playerClosed')
  47. }
  48. }
  49. }
  50. export default Flash