Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziir/aa8ae3af995df6a40de0ead650a81ac3 to your computer and use it in GitHub Desktop.
Save ziir/aa8ae3af995df6a40de0ead650a81ac3 to your computer and use it in GitHub Desktop.
Firefox Mobile (Android) can't use an ObjectURL from a local File after using history.pushState
<html>
<body>
<input type="file" id="file" accept="audio/mpeg" />
</body>
<script>
const input = document.getElementById('file');
input.addEventListener('change', (evt) => {
const file = evt.target.files[0];
history.pushState({}, 'Uploaded', '/uploaded');
const audio = new Audio(URL.createObjectURL(file));
audio.addEventListener('error', () => {
// MediaError { code: 4, message: "2152857618: Request failed" } MEDIA_ERR_SRC_NOT_SUPPORTED
// MediaError { code: 4, message: "Failed to open channel" } MEDIA_ERR_SRC_NOT_SUPPORTED
console.log(audio.error);
});
audio.autoplay = true;
});
</script>
</html>
@ziir
Copy link
Author

ziir commented Jun 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment