2015-07-08 22:54:07 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import Button from 'react-bootstrap/lib/Button';
|
|
|
|
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
|
|
|
|
|
|
|
import MediaPlayer from './../ascribe_media/media_player';
|
|
|
|
|
|
|
|
import CollapsibleButton from './../ascribe_collapsible/collapsible_button';
|
|
|
|
|
2015-07-14 11:11:28 +02:00
|
|
|
import AclProxy from '../acl_proxy';
|
|
|
|
|
2015-07-08 22:54:07 +02:00
|
|
|
|
|
|
|
let MediaContainer = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
content: React.PropTypes.object
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let thumbnail = this.props.content.thumbnail;
|
|
|
|
let mimetype = this.props.content.digital_work.mime;
|
|
|
|
let embed = null;
|
|
|
|
let extraData = null;
|
2015-07-15 12:18:29 +02:00
|
|
|
let isEmbedDisabled = mimetype === 'video' && this.props.content.digital_work.isEncoding !== undefined && this.props.content.digital_work.isEncoding !== 100;
|
2015-07-08 22:54:07 +02:00
|
|
|
|
|
|
|
if (this.props.content.digital_work.encoding_urls) {
|
|
|
|
extraData = this.props.content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (['video', 'audio'].indexOf(mimetype) > -1){
|
|
|
|
embed = (
|
|
|
|
<CollapsibleButton
|
|
|
|
button={
|
2015-07-15 12:18:29 +02:00
|
|
|
<Button bsSize="xsmall" className="ascribe-margin-1px" disabled={isEmbedDisabled ? '"disabled"' : ''}>
|
2015-07-08 22:54:07 +02:00
|
|
|
Embed
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
panel={
|
|
|
|
<pre className="">
|
|
|
|
{'<iframe width="560" height="315" src="http://embed.ascribe.io/content/'
|
2015-07-15 12:18:29 +02:00
|
|
|
+ this.props.content.bitcoin_id + '" frameborder="0" allowfullscreen></iframe>'}
|
2015-07-08 22:54:07 +02:00
|
|
|
</pre>
|
|
|
|
}/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div>
|
2015-07-15 12:18:29 +02:00
|
|
|
<MediaPlayer
|
2015-07-15 11:47:14 +02:00
|
|
|
mimetype={mimetype}
|
|
|
|
preview={thumbnail}
|
|
|
|
url={this.props.content.digital_work.url}
|
2015-07-15 12:21:31 +02:00
|
|
|
extraData={extraData}
|
|
|
|
encodingStatus={this.props.content.digital_work.isEncoding} />
|
2015-07-08 22:54:07 +02:00
|
|
|
<p className="text-center">
|
2015-07-14 11:11:28 +02:00
|
|
|
<AclProxy
|
|
|
|
aclObject={this.props.content.acl}
|
|
|
|
aclName="acl_download">
|
|
|
|
<Button bsSize="xsmall" className="ascribe-margin-1px" href={this.props.content.digital_work.url} target="_blank">
|
|
|
|
Download <Glyphicon glyph="cloud-download"/>
|
|
|
|
</Button>
|
|
|
|
</AclProxy>
|
2015-07-08 22:54:07 +02:00
|
|
|
{embed}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default MediaContainer;
|