mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
41 lines
1.1 KiB
JavaScript
Executable file
41 lines
1.1 KiB
JavaScript
Executable file
// UI and App logic
|
|
import Media from './media';
|
|
import {
|
|
setSkinFromUrl,
|
|
setVolume,
|
|
setPreamp,
|
|
setBalance,
|
|
loadMediaFromUrl,
|
|
loadFileFromReference
|
|
} from './actionCreators';
|
|
import '../css/winamp.css';
|
|
|
|
const fileInput = document.createElement('input');
|
|
fileInput.type = 'file';
|
|
fileInput.style.display = 'none';
|
|
|
|
module.exports = {
|
|
media: Media.init(fileInput),
|
|
fileInput: fileInput,
|
|
init: function(options) {
|
|
this.fileInput.addEventListener('change', (e) => {
|
|
this.dispatch(loadFileFromReference(e.target.files[0]));
|
|
});
|
|
|
|
this.dispatch(setVolume(options.volume));
|
|
this.dispatch(setBalance(options.balance));
|
|
this.dispatch(setPreamp(this.media, 50));
|
|
this.dispatch(loadMediaFromUrl(options.mediaFile.url, options.mediaFile.name));
|
|
this.dispatch(setSkinFromUrl(options.skinUrl));
|
|
return this;
|
|
},
|
|
|
|
/* Functions */
|
|
seekToPercentComplete: function(percent) {
|
|
this.media.seekToPercentComplete(percent);
|
|
},
|
|
|
|
seekForwardBy: function(seconds) {
|
|
this.media.seekToTime(this.media.timeElapsed() + seconds);
|
|
}
|
|
};
|