diff --git a/src/components/Audioplayer/index.js b/src/components/Audioplayer/index.js index 3725a348c..eaf4a6aa0 100644 --- a/src/components/Audioplayer/index.js +++ b/src/components/Audioplayer/index.js @@ -59,7 +59,11 @@ export class Audioplayer extends Component { return buildOnClient(surah.id); } - return this.handleAddFileListeners(currentFile); + if (currentFile) { + return this.handleAddFileListeners(currentFile); + } + + return false; } componentWillReceiveProps(nextProps) { @@ -247,7 +251,7 @@ export class Audioplayer extends Component { handleAddFileListeners(file) { const { update, currentTime } = this.props; // eslint-disable-line no-shadow - debug('component:Audioplayer', `Attaching listeners to ${file.src}`); + console.log('component:Audioplayer', `Attaching listeners to ${file.src}`); // Preload file file.setAttribute('preload', 'auto'); diff --git a/src/containers/Surah/index.js b/src/containers/Surah/index.js index a9289655b..e754816d1 100644 --- a/src/containers/Surah/index.js +++ b/src/containers/Surah/index.js @@ -161,7 +161,9 @@ class Surah extends Component { if (ayahNum > (this.getLast() + 10) || ayahNum < this.getFirst()) { // This is beyond lazy loading next page. - return actions.push.push(`/${surah.id}/${ayahNum}-${ayahNum + 10}`); + if (actions.push) { + return actions.push.push(`/${surah.id}/${ayahNum}-${ayahNum + 10}`); + } } return this.handleLazyLoadAyahs(() => setTimeout(() => diff --git a/src/redux/modules/audioplayer.js b/src/redux/modules/audioplayer.js index 3c276b9de..e9635c321 100644 --- a/src/redux/modules/audioplayer.js +++ b/src/redux/modules/audioplayer.js @@ -152,19 +152,32 @@ export default function reducer(state = initialState, action = {}) { }; } case PLAY: { - state.currentFile.play(); - return { - ...state, - isPlaying: true - }; + + if (state.currentFile) { + state.currentFile.play(); + return { + ...state, + isPlaying: true + }; + } + + return state; + } case PAUSE: { - state.currentFile.pause(); - return { - ...state, - isPlaying: false - }; + if (state.currentFile) { + state.currentFile.pause(); + + return { + ...state, + isPlaying: false + }; + } + + return state; + + } case NEXT: { const [surahId, ayahNum] = action.currentAyah.split(':');