Skip to content

Commit

Permalink
Unmute iOS devices on play
Browse files Browse the repository at this point in the history
  • Loading branch information
stufreen committed Aug 2, 2023
1 parent d8a682a commit 285d010
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A drum machine and sequencer built with the Web Audio API and React.",
"main": "dist/index.html",
"scripts": {
"start": "vite",
"start": "vite --host",
"build": "rm -rf dist && vite build",
"lint": "eslint src",
"test": "jest",
Expand Down
Binary file added src/assets/silence.mp3
Binary file not shown.
2 changes: 2 additions & 0 deletions src/common/playbackSession/playbackSession.actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PLAYBACK_SESSION_CONSTANTS } from './playbackSession.constants';
import { getAudioContext } from '../../services/audioContext';
import { unmute } from '../../services/unmute';

export const startPlayback = () => ({
type: PLAYBACK_SESSION_CONSTANTS.START_PLAYBACK,
Expand All @@ -15,6 +16,7 @@ export const setStartTime = (val) => ({
});

export const startPlaybackAndResume = () => (dispatch) => {
unmute();
getAudioContext().resume();
dispatch(startPlayback());
};
7 changes: 7 additions & 0 deletions src/services/unmute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import silence from '../assets/silence.mp3';

export const unmute = () => {
var el = document.createElement('audio');
el.src = silence;
el.play();
};

0 comments on commit 285d010

Please sign in to comment.