Skip to content
Snippets Groups Projects
Commit b11d52df authored by Sami Spets's avatar Sami Spets
Browse files

THUMBNAIL WORKINGgit add .!

parent 68735328
No related branches found
No related tags found
No related merge requests found
Pipeline #14704 passed
import React, {Component} from 'react'; import React, {Component} from 'react';
const Thumbnail = ({thumbnail}) => { class Thumbnail extends Component {
const renderThumbnails = async () => { constructor(props){
super(props)
this.state = {imgSrc: ''}
}
componentDidMount(){
this.renderThumbnails()
}
fetchThumbnails = async () => {
const jsonThumbnails = await fetch('http://localhost:8080/streams/')
const realThumbnails = await jsonThumbnails.json();
console.log('REAL THUMBNAILS', realThumbnails)
return realThumbnails;
}
renderThumbnails = async () => {
let returnVal = "err"; let returnVal = "err";
const encodedURI = encodeURIComponent(thumbnail) console.log(this.props)
console.log(encodedURI) const thumbs = await this.fetchThumbnails()
console.log(thumbs);
const encodedURI = encodeURIComponent(thumbs[0])
console.log('ENCODED', encodedURI)
try{ try{
const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`) const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`)
console.log(someData) console.log(someData)
...@@ -15,18 +34,21 @@ const Thumbnail = ({thumbnail}) => { ...@@ -15,18 +34,21 @@ const Thumbnail = ({thumbnail}) => {
console.log('MYBLOB', myBlob) console.log('MYBLOB', myBlob)
const objectURL = URL.createObjectURL(myBlob); const objectURL = URL.createObjectURL(myBlob);
console.log('URL ', objectURL); console.log('URL ', objectURL);
return objectURL; this.setState({imgSrc: objectURL});
} catch(err){ } catch(err){
console.log('Kurwavaara:', err); console.log('Kurwavaara:', err);
} }
console.log('RETURN VALUE', returnVal)
return returnVal;
} }
return ( render(){
<div> const val = this.state.imgSrc
<img src={renderThumbnails()} alt="Hups"></img> return (
</div> <div>
) {console.log('SRC', this.state.imgSrc)}
<img src={val} width='500px'></img>
<button onClick={() => this.renderThumbnails()}></button>
</div>
)
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment