Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import ArchiveAudioPlayer from './archive-audio-jwplayer-wrapper';
import ThirdPartyEmbeddedPlayer from './third-party-embed';
import HorizontalRadioGroup from '../selectors/horizontal-radio-group/horizontal-radio-group';
import BookReaderWrapper from '../bookreader-component/bookreader-wrapper-main';
import YoutubePlayer from './youtube-player';
/**
* Draw background photo
* if none, then show media icon
*/
const drawBackgroundPhoto = ({ backgroundPhoto, photoAltTag }) => {
const mediaIcon = <i className="no-photo iconochive-audio" />;
const image = backgroundPhoto
? (
<img
className="background-photo"
src={backgroundPhoto}
alt={photoAltTag}
/>
)
: mediaIcon;
return image;
};
/**
* Theatre Audio Player
* This is the main controller or the audio player
* It will toggle between IA player & third party player
*
* When we have liner notes, this will also be responsible for
* toggling between liner notes & player while continuing to play audio
*
* Props:
* @param array availableMedia
*/
export default class TheatreAudioPlayer extends Component {
constructor(props) {
super(props);
this.state = {
mediaSource: 'player'
};
this.showMedia = this.showMedia.bind(this);
this.createTabs = this.createTabs.bind(this);
this.toggleMediaSource = this.toggleMediaSource.bind(this);
this.showLinerNotes = this.showLinerNotes.bind(this);
}
/**
* Toggles between available tabs, currently: player, liner notes
*
* @param { object } event - React Synthetic event
*/
toggleMediaSource(event) {
const mediaSource = event.target.value;
this.setState({ mediaSource });
}
/**
* Render function - Choose player according to `source
*/
showMedia() {
const { source, sourceData, playlist } = this.props;
const isExternal = source === 'youtube' || source === 'spotify';
let mediaElement = null;
const externalSourceDetails = sourceData[source] || {};
const {
urlPrefix = '', id = '', urlExtensions = '', name = ''
} = externalSourceDetails;
Iif (source === 'youtube') {
const { trackNumber } = sourceData;
mediaElement = (
<YoutubePlayer
selectedTrack={trackNumber}
id={id}
playlist={playlist}
{...this.props}
/>
);
} else Eif (source === 'spotify') {
const sourceURL = `${urlPrefix}${id}${urlExtensions}`;
mediaElement = (
<ThirdPartyEmbeddedPlayer
sourceURL={sourceURL}
title={name}
/>
);
}
const archiveStyle = isExternal ? { visibility: 'hidden' } : { visibility: 'visible' };
return (
<Fragment>
<ArchiveAudioPlayer
{...this.props}
style={archiveStyle}
/>
{ mediaElement }
</Fragment>
);
}
/**
* Render function - create tabs that live under the main content area
*/
createTabs() {
const { customSourceLabels, linerNotes } = this.props;
const { mediaSource } = this.state;
const sourceLabel = {
value: 'player',
label: customSourceLabels.player,
};
const options = [sourceLabel];
Iif (linerNotes) {
options.push({
value: 'liner-notes',
label: customSourceLabels.linerNotes,
});
}
return (
<HorizontalRadioGroup
options={options}
onChange={this.toggleMediaSource}
selectedValue={mediaSource}
wrapperStyle="tab-bottom"
name="audio-theatre-tabs"
/>
);
}
/**
* Render function - determines whether or not we render liner notes
*/
showLinerNotes() {
const {
linerNotes, userSignedIn, albumMetadata, baseHost
} = this.props;
const { mediaSource } = this.state;
// may have linerNotes with just {metadata} if bookreader jsia call fails
Eif (!linerNotes || !linerNotes.data) return null;
const bookReaderStyle = mediaSource === 'liner-notes'
? { visibility: 'visible' }
: { visibility: 'hidden' };
return (
<div style={bookReaderStyle}>
<BookReaderWrapper
options={{ ...linerNotes.data.brOptions }}
userSignedIn={userSignedIn}
baseHost={baseHost}
item={albumMetadata}
style={{
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
backgroundColor: 'black',
}}
/>
</div>
);
}
render() {
// Make sure content window stays the same when toggling between sources
// the JWplayer controls sit UNDER the album photo
// while the other players overtake the whole content-window
// We will have to accomodate the window's fixed height here.
const { backgroundPhoto, playlist } = this.props;
const hasTracks = !!playlist.length;
const mediaPlayerClass = hasTracks && backgroundPhoto ? 'no-waveform' : 'with-waveform';
const noAlbumCoverClass = backgroundPhoto ? '' : 'no-cover';
return (
<section className="theatre__audio-player">
<div className="content-window">
<div className={`album-cover ${noAlbumCoverClass}`}>
{drawBackgroundPhoto(this.props)}
</div>
<div className={`media-player ${mediaPlayerClass}`}>
{this.showMedia()}
{this.showLinerNotes()}
</div>
</div>
<div className="tabs">
{this.createTabs()}
</div>
</section>
);
}
}
TheatreAudioPlayer.displayName = 'TheatreAudioPlayer';
TheatreAudioPlayer.defaultProps = {
backgroundPhoto: '',
photoAltTag: '',
urlExtensions: '',
linerNotes: null,
albumMetadata: null,
userSignedIn: false,
baseHost: ''
};
TheatreAudioPlayer.propTypes = {
source: PropTypes.oneOf([
'youtube',
'spotify',
'archive',
]).isRequired,
sourceData: PropTypes.shape({
urlPrefix: PropTypes.string,
id: PropTypes.string,
mediaName: PropTypes.string,
}).isRequired,
urlExtensions: PropTypes.string,
backgroundPhoto: PropTypes.string,
photoAltTag: PropTypes.string,
customSourceLabels: PropTypes.object,
linerNotes: PropTypes.object,
playlist: PropTypes.array.isRequired,
albumMetadata: PropTypes.object,
userSignedIn: PropTypes.bool,
baseHost: PropTypes.string
};
|