It only happens if there are no valid sources.Įxcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. Danger zone within makes play() promise never rejectsĮxpected as the video doesn't exist. Play promise supportĪt the time of writing, ay() returns a promise inĬhrome, Edge, Firefox, Opera, and Safari. You'll lose the "user gesture token" required to allow Warning: Don't make your onButtonClick function asynchronous with the async This will allow us to play video later. You don't have to use ay(), you can useīutton.addEventListener('click', onButtonClick) That's great for this simple example but what if you use ay() to be Started, meaning the code inside the then() will not execute until the media Worth noting that the Promise won't fulfill until playback has actually The Promise returned by the play function to see if it was rejected. Now that we understand the root cause, let's see what we can do to fix this.įirst, don't ever assume a media element (video or audio) will play. You canĮntirely reset the video playback state, including the buffer, with Note: Calling video.pause() isn't the only way to interrupt a video. Since we're not handling the video play Promise in our code, an error messageĪppears in Chrome DevTools. video.pause() interrupts video loading because it is not ready yet.ay() starts loading video content asynchronously.Rejected along with an error message explaining the failure. If playback succeeds, the Promise is fulfilled and the Moreover since Chrome 50, a play() call on an a or Įlement returns a Promise, a function that returns a single resultĪsynchronously. Necessarily start immediately after ay() is executed. The code above results in this error message in Chrome DevTools:Īs the video is not loaded due to preload="none", video playback doesn't Here's some JavaScript code below that reproduces the "Uncaught (in promise)" Uncaught (in promise) DOMException: The play() request was interrupted by a Perform a column selection by by draggingĭid you just stumble upon this unexpected media error in the Chrome DevTools.Copy the response of a network resource to your clipboard. High performance video with hardware decoding.Go to a line number at a specific column.Get notified of JS errors while you type.Use keyboard to navigate through callstack.Toggle the DevTools dock state with a keyboard shortcut.Quickly monitor events from the Console Panel.Command click to add multiple cursors in the Sources Panel.Some UI and feature enhancements to the Color Picker tool.Notifying you of Changes to Notifications.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |