2021-04-11 20:03:03 +00:00
|
|
|
import RuffleService from '../../services/ruffle_service/ruffle_service.js'
|
2021-04-11 21:00:23 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
2021-04-12 21:08:17 +00:00
|
|
|
import {
|
|
|
|
faStop,
|
|
|
|
faExclamationTriangle
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
2021-04-11 21:00:23 +00:00
|
|
|
|
|
|
|
library.add(
|
2021-04-12 21:08:17 +00:00
|
|
|
faStop,
|
|
|
|
faExclamationTriangle
|
2021-04-11 21:00:23 +00:00
|
|
|
)
|
2021-04-11 20:03:03 +00:00
|
|
|
|
2021-04-09 16:09:22 +00:00
|
|
|
const Flash = {
|
2021-04-11 20:03:03 +00:00
|
|
|
props: [ 'src' ],
|
2021-04-11 21:00:23 +00:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
player: false, // can be true, "hidden", false. hidden = element exists
|
|
|
|
loaded: false,
|
|
|
|
ruffleInstance: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
openPlayer () {
|
2021-04-12 21:08:17 +00:00
|
|
|
if (this.player) return // prevent double-loading, or re-loading on failure
|
2021-04-11 21:00:23 +00:00
|
|
|
this.player = 'hidden'
|
2021-04-11 20:03:03 +00:00
|
|
|
RuffleService.getRuffle().then((ruffle) => {
|
|
|
|
const player = ruffle.newest().createPlayer()
|
2021-04-11 21:00:23 +00:00
|
|
|
player.config = {
|
|
|
|
letterbox: 'on'
|
|
|
|
}
|
2021-04-11 21:52:16 +00:00
|
|
|
const container = this.$refs.container
|
2021-04-11 20:03:03 +00:00
|
|
|
container.appendChild(player)
|
2021-04-11 21:00:23 +00:00
|
|
|
player.style.width = '100%'
|
|
|
|
player.style.height = '100%'
|
|
|
|
player.load(this.src).then(() => {
|
|
|
|
this.player = true
|
2021-04-12 21:08:17 +00:00
|
|
|
}).catch((e) => {
|
|
|
|
console.error('Error loading ruffle', e)
|
|
|
|
this.player = 'error'
|
2021-04-11 21:00:23 +00:00
|
|
|
})
|
|
|
|
this.ruffleInstance = player
|
2021-06-17 13:29:46 +00:00
|
|
|
this.$emit('playerOpened')
|
2021-04-11 20:03:03 +00:00
|
|
|
})
|
2021-04-11 21:00:23 +00:00
|
|
|
},
|
|
|
|
closePlayer () {
|
2021-06-17 13:29:46 +00:00
|
|
|
this.ruffleInstance && this.ruffleInstance.remove()
|
2021-04-11 21:00:23 +00:00
|
|
|
this.player = false
|
2021-06-17 13:29:46 +00:00
|
|
|
this.$emit('playerClosed')
|
2021-04-11 21:00:23 +00:00
|
|
|
}
|
2021-04-09 16:09:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Flash
|