Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #67 from moonwave99/quality/remove-groove-deps
Browse files Browse the repository at this point in the history
(quality) Remove groove deps
  • Loading branch information
moonwave99 authored Aug 31, 2017
2 parents dceb328 + 04f0670 commit 26fdd22
Show file tree
Hide file tree
Showing 20 changed files with 447 additions and 326 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/ui/**/*.js
__data__
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ So now that I found a solid match between a low level audio player, and an appli

## Install

Playa delivers sound to your loudspeakers (and eventually to your ears) via [libgroove](https://github.com/andrewrk/libgroove).
As I haven't found a way to pack it with the app itself yet, you have to install it via `brew`:

$ brew install libgroove

Then either [download the latest build from here](https://github.com/moonwave99/playa/releases), or build manually:
Either [download the latest build from here](https://github.com/moonwave99/playa/releases), or build manually:

$ npm install
$ gulp release
Expand Down
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
"url": "http://github.com/moonwave99/playa/raw/master/LICENSE.md"
}
],
"build": {
"asarUnpack": [
"**/node_modules/ffmpeg/*"
]
},
"dependencies": {
"app-root-dir": "^1.0.2",
"async": "1.4.0",
"bluebird": "2.9.27",
"bootstrap-styl": "^4.0.4",
Expand All @@ -32,6 +38,7 @@
"emissary": "^1.3.1",
"enquire.js": "^2.1.1",
"express": "^4.13.4",
"ffbinaries": "^1.0.2",
"fluent-ffmpeg": "^2.0.1",
"font-awesome": "^4.5.0",
"fs-extra": "^0.20.1",
Expand All @@ -40,7 +47,6 @@
"fs-promise": "^1.0.0",
"fstream": "0.1.24",
"glob": "^5.0.10",
"groove": "^2.4.0",
"i18next": "^6.0.2",
"js-yaml": "^3.3.1",
"keymaster": "^1.6.2",
Expand All @@ -57,8 +63,8 @@
"path-extra": "^3.0.0",
"property-accessors": "^1",
"react": "^0.14",
"react-dnd": "^1.1.3",
"react-dnd-html5-backend": "^2.1.2",
"react-dnd": "^2.4.0",
"react-dnd-html5-backend": "^2.4.1",
"react-dom": "^0.14.6",
"react-list": "^0.7.0",
"react-simpletabs": "^0.7.0",
Expand All @@ -72,17 +78,17 @@
"underscore-plus": "^1.6.1",
"vm-compatibility-layer": "0.1.0",
"walkdir": "0.0.10",
"waveform": "^2.0.0",
"wavesurfer.js": "[email protected]:katspaugh/wavesurfer.js.git#2.0.0-beta01",
"yargs": "^1.3.3"
},
"devDependencies": {
"babel-core": "^6.22.0",
"babel-preset-es2015-rollup": "^3.0.0",
"babel-preset-react": "^6.22.0",
"babel-register": "^6.22.0",
"electron": "1.4.13",
"electron-packager": "8.5.1",
"electron-rebuild": "^1.5.7",
"electron": "1.6.11",
"electron-packager": "9.0.0",
"electron-rebuild": "^1.6.0",
"eslint": "^3.14.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
Expand Down Expand Up @@ -114,7 +120,7 @@
"test": "tape -r babel-register src/**/*.spec.js | faucet",
"eslint": "eslint --ext .js,.jsx src",
"postinstall": "make postinstall",
"rebuild": "./node_modules/.bin/electron-rebuild -v 1.4.13",
"rebuild": "./node_modules/.bin/electron-rebuild -v 1.6.11",
"localInstall": "cp -r ./release/Playa-darwin-x64/Playa.app/ /Applications/Playa.app/"
},
"private": true
Expand Down
20 changes: 9 additions & 11 deletions src/config/default.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const path = require('path');
const appRootDir = require('app-root-dir').get();

export default {
ffmpegPath: '/usr/local/bin/ffmpeg',
ffprobePath: '/usr/local/bin/ffprobe',
ffmpegPath: path.join(appRootDir, 'node_modules/ffmpeg/ffmpeg'),
ffprobePath: path.join(appRootDir, 'node_modules/ffmpeg/ffprobe'),
coverFolderName: 'Covers',
waveformFolderName: 'Waveforms',
playlistFolderName: 'Playlists',
coverLoaderLog: false,
waveformLoader: {
log: false,
wait: 300,
'png-width': 1600,
'png-height': 160,
'png-color-bg': '00000000',
'png-color-center': '505050FF',
'png-color-outer': '505050FF',
wavesurfer: {
waveColor: '#7f7f7f',
progressColor: '#bfbfbf',
height: 140,
},
fileExtensions: ['mp3', 'm4a', 'flac', 'ogg'],
playlistExtension: '.yml',
Expand Down
20 changes: 9 additions & 11 deletions src/playa.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { omit, map } from 'lodash';
import { map } from 'lodash';
import fs from 'fs-extra';
import fsPlus from 'fs-plus';
import md5 from 'md5';
Expand All @@ -15,7 +15,6 @@ import AlbumPlaylist from './renderer/util/AlbumPlaylist';
import PlaylistLoader from './renderer/util/PlaylistLoader';
import MediaFileLoader from './renderer/util/MediaFileLoader';
import CoverLoader from './renderer/util/CoverLoader';
import WaveformLoader from './renderer/util/WaveformLoader';
import LastFMClient from './renderer/util/LastFMClient';
import { formatTimeShort as formatTime } from './renderer/util/helpers/formatters';
import AppDispatcher from './renderer/dispatcher/AppDispatcher';
Expand Down Expand Up @@ -99,7 +98,6 @@ export default class Playa {
scrobbleThreshold: this.getSetting('config', 'lastFM').scrobbleThreshold,
storeFolders: {
covers: this.getSetting('config', 'coverFolderName'),
waveforms: this.getSetting('config', 'waveformFolderName'),
playlists: this.getSetting('config', 'playlistFolderName'),
},
},
Expand Down Expand Up @@ -173,13 +171,6 @@ export default class Playa {
}),
});

const waveformSettings = this.getSetting('config', 'waveformLoader');
this.waveformLoader = new WaveformLoader({
root: path.join(options.userDataFolder, this.getSetting('common', 'storeFolders').waveforms),
enableLog: waveformSettings.log,
config: omit(waveformSettings, 'log'),
});

this.openPlaylistManager = new OpenPlaylistManager({
loader: this.playlistLoader,
mediaFileLoader: this.mediaFileLoader,
Expand All @@ -198,12 +189,15 @@ export default class Playa {
mediaFileLoader: this.mediaFileLoader,
resolution: 1000,
scrobbleThreshold: this.getSetting('common', 'scrobbleThreshold'),
audioElement: options.audioElement,
});

ffmpeg.setFfmpegPath(this.getSetting('config', 'ffmpegPath'));
ffmpeg.setFfprobePath(this.getSetting('config', 'ffprobePath'));

this._onOpenPlaylistChange = this._onOpenPlaylistChange.bind(this);
this.saveSetting = this.saveSetting.bind(this);
this.toggleSidebar = this.toggleSidebar.bind(this);
}
init() {
this.firstPlaylistLoad = false;
Expand Down Expand Up @@ -459,7 +453,11 @@ export default class Playa {
}
render() {
ReactDOM.render(
React.createElement(Main, this.settings.ui.all()),
React.createElement(Main, Object.assign({
lastFMClient: this.lastFMClient,
toggleSidebar: this.toggleSidebar,
wavesurferSettings: this.getSetting('config', 'wavesurfer'),
}, this.settings.ui.all())),
document.getElementById('main'),
);
this.postRender();
Expand Down
17 changes: 14 additions & 3 deletions src/renderer/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Main extends Component {
enquire.register(minWidth(this.props.breakpoints.widescreen), {
match: () => {
if (this.state.settings.user.openSidebar) {
playa.toggleSidebar(true);
this.props.toggleSidebar(true);
}
},
unmatch: () => {},
Expand Down Expand Up @@ -202,9 +202,11 @@ class Main extends Component {
return (
<div className={classes} onClick={handleGlobalClick}>
<Modal {...this.state.modal} />
<PlaybackBar />
<PlaybackBar
wavesurferSettings={this.props.wavesurferSettings}
/>
<Sidebar
lastFMClient={playa.lastFMClient}
lastFMClient={this.props.lastFMClient}
settings={this.state.settings}
{...this.state.sidebar}
/>
Expand Down Expand Up @@ -236,6 +238,15 @@ Main.propTypes = {
widescreen: PropTypes.string,
widefont: PropTypes.string,
}),
lastFMClient: PropTypes.shape({

}),
toggleSidebar: PropTypes.func,
wavesurferSettings: PropTypes.shape({
waveColor: PropTypes.String,
progressColor: PropTypes.String,
height: PropTypes.Number,
}),
};

export default dragDropContext(HTML5Backend)(Main);
15 changes: 13 additions & 2 deletions src/renderer/components/player/PlaybackBar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { Component, PropTypes } from 'react';
import cx from 'classnames';
import { formatTimeShort as formatTime } from '../../util/helpers/formatters';
import PlayerStore from '../../stores/PlayerStore';
Expand Down Expand Up @@ -115,7 +115,10 @@ class PlaybackBar extends Component {
</button>
</div>
<div className={wrapperClasses}>
<ProgressBar seekTo={seekTo} {...this.state} />
<ProgressBar
wavesurferSettings={this.props.wavesurferSettings}
seekTo={seekTo} {...this.state}
/>
{ this.renderCover() }
<span
className="playback-time-indicator time-progress"
Expand All @@ -139,4 +142,12 @@ class PlaybackBar extends Component {
}
}

PlaybackBar.propTypes = {
wavesurferSettings: PropTypes.shape({
waveColor: PropTypes.String,
progressColor: PropTypes.String,
height: PropTypes.Number,
}),
};

export default PlaybackBar;
45 changes: 29 additions & 16 deletions src/renderer/components/player/ProgressBar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import wavesurfer from 'wavesurfer.js';

class ProgressBar extends Component {
constructor(props) {
Expand All @@ -9,18 +10,22 @@ class ProgressBar extends Component {
this.handleMouseMove = this.handleMouseMove.bind(this);
this.updateWaveform = this.updateWaveform.bind(this);
}
componentDidMount() {
this.wavesurfer = wavesurfer.create(
Object.assign(this.props.wavesurferSettings, {
container: this.waveform,
interact: false,
}),
);
this.wavesurfer.on('ready', () => {
this.waveform.classList.add('loaded');
});
}
componentDidUpdate(prevProps) {
if (!this.props.currentTrack) {
this.updateWaveform(null);
} else if (
this.props.currentTrack
&& (!prevProps.currentTrack || prevProps.currentTrack.id !== this.props.currentTrack.id)
) {
this.updateWaveform(null);
playa.waveformLoader.load(this.props.currentTrack)
.then(this.updateWaveform)
.catch( err => console.error(err, err.stack)); // eslint-disable-line
}
this.updateWaveform(this.props.currentTrack, prevProps.currentTrack);
}
componentWillUnmount() {
this.wavesurfer.unAll();
}
handleMouseEnter() {
this.cursor.style.opacity = '1';
Expand All @@ -46,12 +51,15 @@ class ProgressBar extends Component {
const percent = ((event.clientX - waveformBounds.left) / waveformBounds.width) * 100;
this.cursor.style.left = `${percent}%`;
}
updateWaveform(waveform) {
if (waveform) {
this.waveform.style.backgroundImage = `url('file://${encodeURI(waveform)}')`;
this.waveform.classList.add('loaded');
} else {
updateWaveform(currentTrack, prevTrack) {
if (!currentTrack) {
this.wavesurfer.empty();
this.waveform.classList.remove('loaded');
} else if (
currentTrack
&& (!prevTrack || prevTrack.id !== currentTrack.id)
) {
this.wavesurfer.load(currentTrack.filename);
}
}
render() {
Expand Down Expand Up @@ -93,6 +101,11 @@ ProgressBar.propTypes = {
id: PropTypes.string,
}),
playing: PropTypes.bool,
wavesurferSettings: PropTypes.shape({
waveColor: PropTypes.String,
progressColor: PropTypes.String,
height: PropTypes.Number,
}),
};

export default ProgressBar;
1 change: 0 additions & 1 deletion src/renderer/components/playlist/AlbumPlaylistItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class AlbumPlaylistItem extends Component {
.catch(() => {});
}
getDisabledContextMenuActions() {
const folder = this.props.album.getFolder();
const label = i18n.t('playlist.album.contextMenu.locateFolderShort');
return [
{
Expand Down
1 change: 1 addition & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ window.playa = new Playa({
userDataFolder: ipc.sendSync('request:app:path', { key: 'userData' }),
sessionInfo: ipc.sendSync('request:session:settings'),
config: config(process.NODE_ENV),
audioElement: document.getElementById('audio'),
});

window.playa.init();
Expand Down
Loading

0 comments on commit 26fdd22

Please sign in to comment.