Did you just stumble upon this unexpected media error in the Chrome DevTools JavaScript Console?
Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().
or
Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.
You’re in the right place then. Have no fear. I’ll explain what is causing this and how to fix it.
What is causing this
Here’s some JavaScript code below that reproduces the “Uncaught (in promise)” error you’re seeing:
<video id="video" preload="none" src="https://example.com/file.mp4"></video>
<script>
video.play(); // <-- This is asynchronous!
video.pause();
</script>
The code above results in this error message in Chrome DevTools:
Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().
As the video is not loaded due to preload="none", video playback doesn’t necessarily start immediately after video.play() is executed.
Moreover since Chrome 50, a play() call on an a <video> or <audio> element returns a Promise, a function that returns a single result asynchronously. If playback succeeds, the Promise is fulfilled and the playing event is fired at the same time. If playback fails, the Promise is rejected along with an error message explaining the failure.
Now here’s what happening:
video.play() starts loading video content asynchronously.
video.pause() interrupts video loading because it is not ready yet.
video.play() rejects asynchronously loudly.
Since we’re not handling the video play Promise in our code, an error message appears in Chrome DevTools.Note: Calling video.pause() isn’t the only way to interrupt a video. You can entirely reset the video playback state, including the buffer, with video.load() and video.src = ''.
How to fix it
Now that we understand the root cause, let’s see what we can do to fix this.
First, don’t ever assume a media element (video or audio) will play. Look at the Promise returned by the play function to see if it was rejected. It is worth noting that the Promise won’t fulfill until playback has actually started, meaning the code inside the then() will not execute until the media is playing.
<video id="video" preload="none" src="https://example.com/file.mp4"></video>
<script>
// Show loading animation.
var playPromise = video.play();
if (playPromise !== undefined) {
playPromise.then(_ => {
// Automatic playback started!
// Show playing UI.
})
.catch(error => {
// Auto-play was prevented
// Show paused UI.
});
}
</script>
<script> // Show loading animation. var playPromise = video.play();
if (playPromise !== undefined) { playPromise.then(_ => { // Automatic playback started! // Show playing UI. // We can now safely pause video... video.pause(); }) .catch(error => { // Auto-play was prevented // Show paused UI. }); } </script>
That’s great for this simple example but what if you use video.play() to be able to play a video later?
I’ll tell you a secret. You don’t have to use video.play(), you can use video.load() and here’s how:
Example: Fetch & Play
<video id="video"></video>
<button id="button"></button>
<script>
button.addEventListener('click', onButtonClick);
function onButtonClick() {
// This will allow us to play video later...
video.load();
fetchVideoAndPlay();
}
function fetchVideoAndPlay() {
fetch('https://example.com/file.mp4')
.then(response => response.blob())
.then(blob => {
video.srcObject = blob;
return video.play();
})
.then(_ => {
// Video playback started ;)
})
.catch(e => {
// Video playback failed ;(
})
}
</script>
Warning: Don’t make your onButtonClick function asynchronous with the async keyword. You’ll lose the “user gesture token” required to allow your video to play later.
In this step by step Angular 8/9/10 SEO tutorial, we are going to learn how to make Angular app SEO friendly by adding the page titles, meta descriptions, keywords, and other SEO attributes in an Angular Universal Server-side rendering app.
Angular offers the Title and Meta services, and these tags are similar HTML meta tags that help in achieving the purpose of making the Angular app SEO friendly.
Meta is a service in Angular, and it belongs to a class family. Angular offers various Meta services to add, read, update, and remove HTML meta elements.
Let us check out the various Meta service methods:
addTag(): Includes one meta tag.
updateTag(): Updates meta tag in angular component.
removeTag(): Removes meta tag for the specified selector.
getTag(): Gets HTMLMetaElement for the specified meta selector.
addTags(): Includes more than one meta tag in angular component.
getTags(): Returns array of HTMLMetaElement for the specified meta selector.
removeTagElement(): Removes meta tag for the specified HTMLMetaElement
In this Angular 8|9 SEO tutorial, we will learn to add, update, HTML meta tag examples for keywords, description, robots, date, author, viewport, charset using Angular Meta service.
Configure Angular Universal Project
We are going to make Angular app SEO compatible, to enable the SEO in Angular, we are going to use Angular universal app. It’s a music app built with MongoDB server-side rendering. Let us take the Git clone from the following Github repo:
Run following command to install the required packages:
npm install
Set up Angular Meta Service
Go to app/app.component.ts file and import Angular Meta service. The Meta service allow us to add keywords, robots, author, viewport, date and charset in Angular
import { Meta } from '@angular/platform-browser';
Now, also add the following code in the same file. Here, we inject the private metaTagService: Meta in the constructor and then used the Meta’s addTags() method to configure the following HTML meta attributes.
Adding SEO Title and Meta Description in Angular Component
Now, we will set Title and Meta Description in Angular Universal app. First import Title, Meta from @angular/platform-browser. Go to app/components/add-song/add-song.component.ts file and add the following code in it.
import { Title, Meta } from '@angular/platform-browser';
@Component({
selector: 'app-add-song',
templateUrl: './add-song.component.html',
styleUrls: ['./add-song.component.css']
})
export class AddSongComponent implements OnInit {
title = 'Add Song - Angular Universal CRUD App';
constructor(
private titleService: Title,
private metaTagService: Meta
) { }
ngOnInit() {
this.titleService.setTitle(this.title);
this.metaTagService.updateTag(
{ name: 'description', content: 'Add song template' }
);
}
}
Here we defined the SEO title with the appropriate value. Then we declared the SEO title with the help of the setTitle() method inside the ngOnInit lifecycle hook.
We also declared the Meta description in Angular with the help of Meta’s updateTag() method.
Adding Canonical URL in Angular 8|9
SEO is the essential element of any site, and Canonical URLs allow search engines about duplicate content. When the site gets bigger, it becomes tedious to prevent web pages from generating duplicate URLs. This problem might lead to a duplicate content issue. A canonical URL provides a professional solution to get rid from duplicate content issues.
Pay your credit card bills & loan EMIs before due date
Consistency of timely payment of credit card bills and EMIs is the most important factor to impact your Credit Score. Please make sure you do not miss bill or EMI due dates as your credit score reduces if there is delay in repayments.
Reduce utilization of Credit Card limits
While you may be paying back your credit card bills on time, high usage of credit cards still indicates too much dependence on available credit line and possible lack of inflow of your own funds. As a result, your Credit Score can get negatively impacted. So, either you should reduce your dependence on credit cards or get credit limits of credit cards increased.
Don’t apply for loans and credit cards with multiple banks
When you apply for any credit card or loan with a financial institution (bank or NBFC). that financial institution fetches your credit card history and score from one or more Credit Bureaus. Basis your credit history and score, financial institution evaluates your ability to repay on time. Now each credit history enquiry by a financial institution is also recorded by same Credit Bureau where enquiry was made. So, if a financial institution sees multiple enquiries on your credit history by other institutions, it considers you to be credit hungry and to be less reliable in repaying on time.
Obtain your Credit Report regularly and check for errors
While you think you have a good credit history, in rare cases there may be certain errors in your credit history reported by your lenders to Credit Bureaus. As a result of those errors, your Credit Score could have reduces considerably. For example, you have completely paid off your personal loan and closed the loan account, but your credit report from Credit Bureau may still be showing up unpaid amount under same personal loan account. In such errors you can either approach any Credit Bureau or your lender to get the correction done.
To install the microsoft loopback adapter on win 10 you must:
right click on window start menu icon and select Device manager. Device manager window will immediately open (or you may use any other way how to open device manager window)
click on Action, and select Add legacy hardware
click Next on welcome screen
choose “Install the hardware that i manually select from a list” and click on Next
scroll down and select Network adapters from offered common hardware types and click on Next
select Microsoft as the manufacturer, and then select Microsoft KM-TEST Loopback adapter card model, click on Next