2023-05-24 01:15:17 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-23 18:52:27 +10:00
|
|
|
import { Component } from 'react';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2020-09-28 21:29:43 +10:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2020-09-28 21:29:43 +10:00
|
|
|
import { removePictureInPicture } from 'mastodon/actions/picture_in_picture';
|
2023-05-24 01:15:17 +10:00
|
|
|
import Audio from 'mastodon/features/audio';
|
|
|
|
import Video from 'mastodon/features/video';
|
|
|
|
|
2020-09-28 21:29:43 +10:00
|
|
|
import Footer from './components/footer';
|
2023-05-24 01:15:17 +10:00
|
|
|
import Header from './components/header';
|
2020-09-28 21:29:43 +10:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
...state.get('picture_in_picture'),
|
|
|
|
});
|
|
|
|
|
2023-05-23 18:52:27 +10:00
|
|
|
class PictureInPicture extends Component {
|
2020-09-28 21:29:43 +10:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
statusId: PropTypes.string,
|
|
|
|
accountId: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
|
|
|
src: PropTypes.string,
|
|
|
|
muted: PropTypes.bool,
|
|
|
|
volume: PropTypes.number,
|
|
|
|
currentTime: PropTypes.number,
|
|
|
|
poster: PropTypes.string,
|
|
|
|
backgroundColor: PropTypes.string,
|
|
|
|
foregroundColor: PropTypes.string,
|
|
|
|
accentColor: PropTypes.string,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleClose = () => {
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
dispatch(removePictureInPicture());
|
2023-01-30 11:45:35 +11:00
|
|
|
};
|
2020-09-28 21:29:43 +10:00
|
|
|
|
|
|
|
render () {
|
|
|
|
const { type, src, currentTime, accountId, statusId } = this.props;
|
|
|
|
|
|
|
|
if (!currentTime) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let player;
|
|
|
|
|
|
|
|
if (type === 'video') {
|
|
|
|
player = (
|
|
|
|
<Video
|
|
|
|
src={src}
|
|
|
|
currentTime={this.props.currentTime}
|
|
|
|
volume={this.props.volume}
|
|
|
|
muted={this.props.muted}
|
|
|
|
autoPlay
|
|
|
|
inline
|
|
|
|
alwaysVisible
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} else if (type === 'audio') {
|
|
|
|
player = (
|
|
|
|
<Audio
|
|
|
|
src={src}
|
|
|
|
currentTime={this.props.currentTime}
|
|
|
|
volume={this.props.volume}
|
|
|
|
muted={this.props.muted}
|
|
|
|
poster={this.props.poster}
|
|
|
|
backgroundColor={this.props.backgroundColor}
|
|
|
|
foregroundColor={this.props.foregroundColor}
|
|
|
|
accentColor={this.props.accentColor}
|
|
|
|
autoPlay
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='picture-in-picture'>
|
|
|
|
<Header accountId={accountId} statusId={statusId} onClose={this.handleClose} />
|
|
|
|
|
|
|
|
{player}
|
|
|
|
|
|
|
|
<Footer statusId={statusId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-24 13:17:53 +11:00
|
|
|
|
|
|
|
export default connect(mapStateToProps)(PictureInPicture);
|