Customisable streaming encoding

This commit is contained in:
James Barnsley
2018-02-02 08:39:37 +13:00
parent 999ed4d7be
commit f05ee674c3
6 changed files with 680 additions and 734 deletions

1
src/js/bootstrap.js vendored
View File

@ -43,6 +43,7 @@ var initialState = {
users: {},
tracks: {},
http_streaming_enabled: false,
http_streaming_encoding: 'mpeg',
http_streaming_url: "http://"+window.location.hostname+":8000/mopidy"
},
ui: {

View File

@ -71,8 +71,8 @@ class PlaybackControls extends React.Component{
return (
<div className={(this.state.expanded ? "expanded playback-controls" : "playback-controls")}>
{this.props.http_streaming ? <audio className="http-streaming" autoPlay>
<source src={this.props.http_streaming} type="audio/mpeg" />
{this.props.http_streaming_enabled && this.props.play_state == 'playing' ? <audio id="http-streamer" autoPlay preload="none">
<source src={this.props.http_streaming_url} type={"audio/"+this.props.http_streaming_encoding} />
</audio> : null}
<div className="current-track">
@ -139,7 +139,9 @@ class PlaybackControls extends React.Component{
const mapStateToProps = (state, ownProps) => {
return {
http_streaming: (state.core.http_streaming_enabled && state.core.http_streaming_url ? state.core.http_streaming_url : ''),
http_streaming_enabled: state.core.http_streaming_enabled,
http_streaming_encoding: state.core.http_streaming_encoding,
http_streaming_url: state.core.http_streaming_url,
current_track: (state.core.current_track && state.core.tracks[state.core.current_track.uri] !== undefined ? state.core.tracks[state.core.current_track.uri] : null),
radio_enabled: (state.ui.radio && state.ui.radio.enabled ? true : false),
play_state: state.mopidy.play_state,

View File

@ -351,8 +351,29 @@ class Settings extends React.Component {
</label>
</div>
</div>
<div className="field radio">
<div className="name">Encoding</div>
<div className="input">
<label>
<input
type="radio"
name="http_streaming_encoding"
checked={this.props.core.http_streaming_encoding == 'mpeg'}
onChange={e => this.props.coreActions.set({http_streaming_encoding: 'mpeg'})} />
<span className="label">mpeg (mp3)</span>
</label>
<label>
<input
type="radio"
name="http_streaming_encoding"
checked={this.props.core.http_streaming_encoding == 'ogg'}
onChange={e => this.props.coreActions.set({http_streaming_encoding: 'ogg'})} />
<span className="label">ogg</span>
</label>
</div>
</div>
<div className="field">
<div className="name">Stream location</div>
<div className="name">Location</div>
<div className="input">
<input
type="text"