import React from 'react'; import ProgressBar from 'components/ProgressBar'; import Request from 'utils/request'; const LOCAL_CHECK = 'LOCAL_CHECK'; const SEARCHING = 'SEARCHING'; const UNAVAILABLE = 'UNAVAILABLE'; const AVAILABLE = 'AVAILABLE'; class AssetDisplay extends React.Component { constructor (props) { super(props); this.state = { error : null, status : LOCAL_CHECK, thumbnail : this.props.thumbnail, src : `/${this.props.claimId}}/${this.props.name}.${this.props.fileExt}`, name : this.props.name, claimId : this.props.claimId, fileExt : this.props.fileExt, contentType: this.props.contentType, }; this.checkIfLocalFileAvailable = this.checkIfLocalFileAvailable.bind(this); this.triggerGetAssetOnSpeech = this.triggerGetAssetOnSpeech.bind(this); } componentDidMount () { const that = this; this.checkIfLocalFileAvailable() .then(isAvailable => { if (!isAvailable) { console.log('file is not yet available'); that.setState({status: SEARCHING}); return that.triggerGetAssetOnSpeech(); } }) .then(() => { that.setState({status: AVAILABLE}); that.addPlayPauseToVideoToBody(); }) .catch(error => { that.setState({ status: UNAVAILABLE, error : error.message, }); }); } checkIfLocalFileAvailable () { console.log(`checking if file is available for ${this.props.name}#${this.props.claimId}`); const url = `/api/file-is-available/${this.props.name}/${this.props.claimId}`; return new Promise((resolve, reject) => { Request(url) .then(isAvailable => { console.log('/api/file-is-available response:', isAvailable); resolve(isAvailable); }) .catch(error => { reject(error); }); }); } triggerGetAssetOnSpeech () { console.log(`getting claim for ${this.props.name}#${this.props.claimId}`) const url = `/api/claim-get/${this.props.name}/${this.props.claimId}`; return new Promise((resolve, reject) => { Request(url) .then(response => { console.log('/api/claim-get response:', response); resolve(true); }) .catch(error => { reject(error); }); }); } addPlayPauseToVideoToBody () { const that = this; const video = document.getElementById('video'); if (video) { // add event listener for click video.addEventListener('click', () => { that.playOrPause(video); }); // add event listener for space bar document.body.onkeyup = (event) => { if (event.keyCode === 32) { that.playOrPause(video); } }; } } playOrPause (video) { if (video.paused === true) { video.play(); } else { video.pause(); } } render () { return (
Sit tight, we're searching the LBRY blockchain for your asset!
Curious what magic is happening here? Learn more.
Unfortunately, we couldn't download your asset from LBRY. You can help us out by sharing the below error message in the LBRY discord.
{this.state.error}
unsupported file type
); } })() }