|
@@ -1,5 +1,6 @@
|
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
|
import Sound from 'react-sound';
|
|
import Sound from 'react-sound';
|
|
|
|
|
+import MediaSession from './MediaSession.js';
|
|
|
import logo from './logo.svg';
|
|
import logo from './logo.svg';
|
|
|
import './App.css';
|
|
import './App.css';
|
|
|
|
|
|
|
@@ -168,7 +169,8 @@ class Player extends Component {
|
|
|
sound: {url: '', playStatus: Sound.status.STOPPED},
|
|
sound: {url: '', playStatus: Sound.status.STOPPED},
|
|
|
tracks: null,
|
|
tracks: null,
|
|
|
activeTrack: -1,
|
|
activeTrack: -1,
|
|
|
- activeAlbum: null
|
|
|
|
|
|
|
+ activeAlbum: null,
|
|
|
|
|
+ metadata: {artist: '', album: '', title: '', cover: ''}
|
|
|
};
|
|
};
|
|
|
for (var {type} of this.categories) {
|
|
for (var {type} of this.categories) {
|
|
|
this.state[type] = Object.assign({}, this.stateLoading);
|
|
this.state[type] = Object.assign({}, this.stateLoading);
|
|
@@ -231,11 +233,19 @@ class Player extends Component {
|
|
|
if (!track) {
|
|
if (!track) {
|
|
|
console.log('Bad activeTrack', this.state.tracks, this.state.activeTrack);
|
|
console.log('Bad activeTrack', this.state.tracks, this.state.activeTrack);
|
|
|
} else {
|
|
} else {
|
|
|
- this.setState({sound: {
|
|
|
|
|
- url: track.url,
|
|
|
|
|
- position: 0,
|
|
|
|
|
- playStatus: Sound.status.PLAYING
|
|
|
|
|
- }})
|
|
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ sound: {
|
|
|
|
|
+ url: track.url,
|
|
|
|
|
+ position: 0,
|
|
|
|
|
+ playStatus: Sound.status.PLAYING
|
|
|
|
|
+ },
|
|
|
|
|
+ metadata: {
|
|
|
|
|
+ title: track.title,
|
|
|
|
|
+ artist: track.artist,
|
|
|
|
|
+ album: track.album,
|
|
|
|
|
+ cover: this.state.activeAlbum.cover
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -344,6 +354,13 @@ class Player extends Component {
|
|
|
onLoading={this.handleSoundLoading}
|
|
onLoading={this.handleSoundLoading}
|
|
|
onPlaying={this.handleSoundPlaying}
|
|
onPlaying={this.handleSoundPlaying}
|
|
|
onFinishedPlaying={this.handleSoundFinished} />
|
|
onFinishedPlaying={this.handleSoundFinished} />
|
|
|
|
|
+ <MediaSession
|
|
|
|
|
+ {...this.state.metadata}
|
|
|
|
|
+ onPlay={this.handleControlPlayPause}
|
|
|
|
|
+ onPause={this.handleControlPlayPause}
|
|
|
|
|
+ onPreviousTrack={this.handleControlPrev}
|
|
|
|
|
+ onNextTrack={this.handleControlNext}
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|