mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 19:13:54 +00:00
Make toggle repeat an action creator
This commit is contained in:
parent
824577b4f0
commit
59dfb34e9d
6 changed files with 12 additions and 11 deletions
|
|
@ -61,6 +61,11 @@ export function adjustVolume(mediaPlayer, volumeDiff) {
|
|||
};
|
||||
}
|
||||
|
||||
export function toggleRepeat(mediaPlayer) {
|
||||
mediaPlayer.toggleRepeat();
|
||||
return {type: 'TOGGLE_REPEAT'};
|
||||
}
|
||||
|
||||
export function setSkinFromFile(skinFile) {
|
||||
return (dispatch) => {
|
||||
dispatch({type: 'START_LOADING'});
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ const MainWindow = (props) => {
|
|||
<Eject />
|
||||
<div className='shuffle-repeat'>
|
||||
<Shuffle />
|
||||
<Repeat />
|
||||
<Repeat mediaPlayer={props.mediaPlayer} />
|
||||
</div>
|
||||
<a id='about' target='blank' href='https://github.com/captbaritone/winamp2-js' />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import React from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {toggleRepeat} from '../actionCreators';
|
||||
|
||||
|
||||
class Repeat extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -8,7 +10,7 @@ class Repeat extends React.Component {
|
|||
this.handleClick = this.handleClick.bind(this);
|
||||
}
|
||||
handleClick() {
|
||||
this.props.dispatch({type: 'TOGGLE_REPEAT'});
|
||||
this.props.dispatch(toggleRepeat(this.props.mediaPlayer));
|
||||
}
|
||||
render() {
|
||||
return <div
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {play, pause, stop, adjustVolume} from './actionCreators';
|
||||
import {play, pause, stop, adjustVolume, toggleRepeat} from './actionCreators';
|
||||
|
||||
module.exports = function(winamp, store) {
|
||||
let keylog = [];
|
||||
|
|
@ -30,7 +30,8 @@ module.exports = function(winamp, store) {
|
|||
case 67: store.dispatch(pause(winamp.media)); break;
|
||||
// L
|
||||
case 76: store.dispatch({type: 'OPEN_FILE_DIALOG'}); break;
|
||||
case 82: winamp.toggleRepeat(); break; // R
|
||||
// R
|
||||
case 82: store.dispatch(toggleRepeat(winamp.media)); break;
|
||||
case 83: winamp.toggleShuffle(); break; // S
|
||||
// V
|
||||
case 86: store.dispatch(stop(winamp.media)); break;
|
||||
|
|
|
|||
|
|
@ -151,9 +151,6 @@ const createReducer = (winamp) => {
|
|||
// TODO: Figure out how to make this pure
|
||||
winamp.openFileDialog();
|
||||
return state;
|
||||
case 'TOGGLE_REPEAT':
|
||||
winamp.toggleRepeat();
|
||||
return state;
|
||||
case 'TOGGLE_SHUFFLE':
|
||||
winamp.toggleShuffle();
|
||||
return state;
|
||||
|
|
|
|||
|
|
@ -56,10 +56,6 @@ module.exports = {
|
|||
this.media.seekToTime(this.media.timeElapsed() + seconds);
|
||||
},
|
||||
|
||||
toggleRepeat: function() {
|
||||
this.media.toggleRepeat();
|
||||
},
|
||||
|
||||
toggleShuffle: function() {
|
||||
this.media.toggleShuffle();
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue