{"id":28411,"date":"2022-03-23T22:58:11","date_gmt":"2022-03-23T22:58:11","guid":{"rendered":"http:\/\/Autoplay-video-with-Intersection-Observer-in-Nuxt.js"},"modified":"2025-03-02T05:15:00","modified_gmt":"2025-03-02T13:15:00","slug":"autoplay-video-with-intersection-observer-in-nuxt-js","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/","title":{"rendered":"Autoplay Video with Intersection Observer"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>A persistent issue facing businesses online is attracting, engaging, and delighting their audience in the few seconds you have their attention. A modest deterioration in user experience may lower conversion rates on websites and platforms, especially for media content such as videos and photos.<\/p>\n<p>This post will show us how to improve the user experience of video content on our website utilizing the autoplay video functionality and the Intersection Observer web API in Nuxt.js.<\/p>\n<h2>Sandbox<\/h2>\n<p>This project was completed in a <a href=\"https:\/\/codesandbox.io\/s\/autoplay-video-with-intersection-observer-in-nuxt-js-l6lps?file=\/pages\/index.vue\">Codesandbox<\/a>. To get started quickly, fork the <a href=\"https:\/\/codesandbox.io\/s\/autoplay-video-with-intersection-observer-in-nuxt-js-l6lps?file=\/pages\/index.vue\">Codesandbox<\/a> to run the project.<\/p>\n<\/div>\n\n\n  <div class=\"wp-block-cloudinary-code-sandbox \">\n    <iframe\n      src=\"https:\/\/codesandbox.io\/embed\/autoplay-video-with-intersection-observer-in-nuxt-js-l6lps?theme=dark&amp;codemirror=1&amp;highlights=&amp;editorsize=50&amp;fontsize=14&amp;expanddevtools=0&amp;hidedevtools=0&amp;eslint=0&amp;forcerefresh=0&amp;hidenavigation=0&amp;initialpath=%2F&amp;module=&amp;moduleview=0&amp;previewwindow=&amp;view=&amp;runonclick=1\"\n      height=\"500\"\n      style=\"width: 100%;\"\n      title=\"Autoplay video with Intersection Observer in Nuxt.js\"\n      loading=\"lazy\"\n      allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n      sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n    ><\/iframe>\n  <\/div>\n\n\n<div class=\"wp-block-cloudinary-markdown \"><h2>GitHub Repository<\/h2>\n<p><a href=\"https:\/\/github.com\/Olanetsoft\/Autoplay-video-with-Intersection-Observer-in-Nuxt.js\">https:\/\/github.com\/Olanetsoft\/Autoplay-video-with-Intersection-Observer-in-Nuxt.js<\/a><\/p>\n<h1>Prerequisite<\/h1>\n<p>The knowledge of JavaScript and Vue.js is needed to follow along in this tutorial. The knowledge of Nuxt.js is not required, but preferred.<\/p>\n<h1>Getting Started with Nuxtjs<\/h1>\n<p><a href=\"https:\/\/nuxtjs.org\/\">Nuxt.js<\/a> is the bedrock of our Vue.js project, providing structure and flexibility while allowing us to scale with confidence.<\/p>\n<p>It is extensible, with a robust module ecosystem and hooks engine that makes it simple to integrate your REST or GraphQL endpoints, favorite CMS, CSS frameworks, and other third-party applications.<\/p>\n<h1>Project Setup and Installation<\/h1>\n<p>To create a new project, we will use the command below to scaffold a new project:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    npx create-nuxt-app <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">project-name<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>A series of prompts will appear as a result of the command. Here are the defaults we recommend:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_96F9621432D8794EA39E7FADB94909BD9E10CD07BE1A0EBEE6C3C51069D531BF_1643148120105_Screenshot+2022-01-21+at+23.38.24.png\" alt=\"Next Setup\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1298\" height=\"414\"\/><\/p>\n<p>Next, we need to navigate into the project directory and start the development server using the command below<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    cd <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">project<\/span> <span class=\"hljs-attr\">name<\/span>&gt;<\/span> &amp;&amp; yarn dev\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Nuxt.js will start a hot-reloading development environment accessible by default at <code>http:\/\/localhost:3000<\/code><\/p>\n<h1>Cloudinary Video Player Installation<\/h1>\n<p>We will use the <a href=\"https:\/\/cloudinary.com\/documentation\/cloudinary_video_player\">Cloudinary Video Player<\/a> to detect and respond to a video player\u2019s state changes.<\/p>\n<p><a href=\"https:\/\/cloudinary.com\/documentation\/cloudinary_video_player\">Cloudinary video player<\/a> is a JavaScript-based HTML5 video player that comes with a slew of useful customization and integration features, as well as monetization and analytics support.<\/p>\n<p>The video player artifacts (JS and CSS) will be added to our <code>nuxt.config.js<\/code> in the <code>link<\/code> and <code>script<\/code> section of the file using the following snippet:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-comment\">\/\/ nuxt.config.js<\/span>\n    \n    <span class=\"hljs-keyword\">export<\/span>  <span class=\"hljs-keyword\">default<\/span>  {\n      <span class=\"hljs-attr\">head<\/span>:  {\n          ...\n      link: &#91;\n          ...\n      {\n        <span class=\"hljs-attr\">rel<\/span>:  <span class=\"hljs-string\">'stylesheet'<\/span>, \n        <span class=\"hljs-attr\">href<\/span>:  <span class=\"hljs-string\">'https:\/\/unpkg.com\/cloudinary-video-player@1.5.9\/dist\/cld-video-player.min.css'<\/span>  \n      }\n            ],\n      <span class=\"hljs-attr\">script<\/span>:  &#91;\n      { \n      <span class=\"hljs-attr\">src<\/span>:  <span class=\"hljs-string\">'https:\/\/unpkg.com\/cloudinary-core@latest\/cloudinary-core-shrinkwrap.min.js'<\/span> \n      },\n      { \n      <span class=\"hljs-attr\">src<\/span>:  <span class=\"hljs-string\">'https:\/\/unpkg.com\/cloudinary-video-player@1.5.9\/dist\/cld-video-player.min.js'<\/span>\n      },\n              ],\n      },\n    };\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>We need to save our Cloudinary cloud name so that we can refer to it from any file. It will be saved as an environment variable in a global <code>.env<\/code> file at the project\u2019s root in the following step.<\/p>\n<p>You can get your cloud name from your <a href=\"https:\/\/cloudinary.com\/users\/register\/free\">Cloudinary dashboard<\/a> by signing up for a Cloudinary account.<\/p>\n<p>Create a <code>.env<\/code> file in the project\u2019s root directory with the command <code>touch .env<\/code> and update it with the following snippet:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    NUXT_ENV_CLOUDINARY_CLOUD_NAME=<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">cloudinary-cloud-name<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>We can now create our video player by updating <code>pages\/index.vue<\/code> with the following code snippet:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"container\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>\n          <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"flex justify-center items-center h-screen space-x-5 px-18 font-bold text-4xl\"<\/span>\n        &gt;<\/span>\n          Autoplay video with Intersection Observer in Nuxt.js\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n    \n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"flex justify-center items-center h-screen space-x-10\"<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"rounded overflow-hidden shadow-lg mb-4 content-center\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"px-6 py-4 pb-2\"<\/span>&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"pb-4 pt-8\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    \n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">video<\/span>\n                <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"video-player\"<\/span>\n                <span class=\"hljs-attr\">controls<\/span>\n                <span class=\"hljs-attr\">width<\/span>=<span class=\"hljs-string\">\"800px\"<\/span>\n                <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"width-full\"<\/span>\n                <span class=\"hljs-attr\">ref<\/span>=<span class=\"hljs-string\">\"theVideo\"<\/span>\n                <span class=\"hljs-attr\">muted<\/span>\n              &gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">video<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>\n    \n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"javascript\">\n    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> {\n     data() {\n        <span class=\"hljs-keyword\">return<\/span> {\n          <span class=\"hljs-attr\">cld<\/span>: <span class=\"hljs-literal\">null<\/span>,\n          <span class=\"hljs-attr\">player<\/span>: <span class=\"hljs-literal\">null<\/span>,\n          <span class=\"hljs-attr\">video<\/span>: <span class=\"hljs-string\">\"\/samples\/animals\/dancing-cat\"<\/span>,\n        };\n      },\n    \n      mounted() {\n        <span class=\"hljs-keyword\">this<\/span>.cld = cloudinary.Cloudinary.new({\n          <span class=\"hljs-attr\">cloud_name<\/span>: process.env.NUXT_ENV_CLOUDINARY_CLOUD_NAME,\n          <span class=\"hljs-attr\">secure<\/span>: <span class=\"hljs-literal\">true<\/span>,\n        });\n    \n        <span class=\"hljs-keyword\">this<\/span>.player = <span class=\"hljs-keyword\">this<\/span>.cld.videoPlayer(<span class=\"hljs-string\">\"video-player\"<\/span>, {\n          <span class=\"hljs-attr\">analytics<\/span>: {\n            <span class=\"hljs-attr\">events<\/span>: &#91;<span class=\"hljs-string\">\"play\"<\/span>, <span class=\"hljs-string\">\"pause\"<\/span>],\n          },\n        });\n    \n        <span class=\"hljs-keyword\">this<\/span>.player.source(<span class=\"hljs-keyword\">this<\/span>.video);\n    \n        <span class=\"hljs-keyword\">this<\/span>.onElementObserved();\n      },\n      <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">\"IndexPage\"<\/span>,\n    };\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>We created a Cloudinary instance, utilized it to initialize the video player, and set up the video source in our mounted lifecycle hook in the code snippet above.<\/p>\n<p>We should have something similar to this below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_96F9621432D8794EA39E7FADB94909BD9E10CD07BE1A0EBEE6C3C51069D531BF_1643149442558_Screenshot+2022-01-25+at+23.20.45.png\" alt=\"Nuxtjs\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"1120\"\/><\/p>\n<p>On scrolling down, we should see the rendered video looking like this.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_96F9621432D8794EA39E7FADB94909BD9E10CD07BE1A0EBEE6C3C51069D531BF_1643149536842_Screenshot+2022-01-25+at+23.21.28.png\" alt=\"Nuxtjs\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"1118\"\/><\/p>\n<p>In this section, we will use the intersection observer API to detect the changes of our video tag\u2019s position relative to the viewport of our website.<\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Intersection_Observer_API\">The Intersection Observer API<\/a> allows you to asynchronously monitor changes in a target element\u2019s intersection with a parent element or a top-level document\u2019s viewport.<\/p>\n<p>Next, We will update the <code>pages\/index.vue<\/code> with the code snippet below:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">    export <span class=\"hljs-keyword\">default<\/span> {\n      data() {\n        <span class=\"hljs-comment\">\/\/...<\/span>\n      },\n    \n      mounted() {\n         <span class=\"hljs-comment\">\/\/...<\/span>\n    \n        this.onElementObserved();\n      },\n    \n      methods: {\n        onElementObserved() {\n          <span class=\"hljs-keyword\">const<\/span> observer = <span class=\"hljs-keyword\">new<\/span> IntersectionObserver((entries) =&gt; {\n            entries.<span class=\"hljs-keyword\">forEach<\/span>((entry) =&gt; {\n              <span class=\"hljs-keyword\">if<\/span> (entry.intersectionRatio &gt; <span class=\"hljs-number\">0<\/span>) {\n                this.player.play();\n              } <span class=\"hljs-keyword\">else<\/span> {\n                this.player.pause();\n              }\n            });\n          });\n          observer.observe(this.$refs.theVideo);\n        },\n      },\n    \n      name: <span class=\"hljs-string\">\"IndexPage\"<\/span>,\n    };\n    &lt;\/script&gt;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the code snippet above:<\/p>\n<ul>\n<li>We added the <code>onElementObserved<\/code> method.<\/li>\n<li>We created an IntersectionObserver instance and iterated through the entries, checking if <code>entry.intersectionRatio<\/code> is greater than 0.<\/li>\n<li>If it\u2019s greater than zero, we set the trigger for the video to start playing, and if not, we pause the video.<\/li>\n<li>Finally, the <code>observe<\/code> method monitors the video element by passing <code>this.$refs.theVideo<\/code>, which references the video element in view.<\/li>\n<\/ul>\n<p>After testing our application, we should get something similar to what we have below.<\/p>\n<p><a href=\"https:\/\/www.loom.com\/share\/aa03ff4633984a55b3dd2b10c5925ad9\">https:\/\/www.loom.com\/share\/aa03ff4633984a55b3dd2b10c5925ad9<\/a><\/p>\n<p><strong>PS<\/strong>: We muted the video using the <code>muted<\/code> attribute to prevent the following error:<\/p>\n<pre><code>Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.\n<\/code><\/pre>\n<p>This is due to Chrome\u2019s autoplay policies changed in April of 2018. You can <a href=\"https:\/\/developer.chrome.com\/blog\/autoplay\/\">learn more about the policy.<\/a><\/p>\n<h1>Conclusion<\/h1>\n<p>This article explained how to autoplay a video using the intersection observer in nuxt.js to enhance user experience.<\/p>\n<h1>Resources<\/h1>\n<p>You may find these resources useful.<\/p>\n<ul>\n<li>\n<a href=\"https:\/\/www.w3schools.com\/tags\/ref_av_dom.asp\">HTML Audio\/Video DOM Reference<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/cloudinary.com\/documentation\/cloudinary_video_playerhttps:\/\/cloudinary.com\/documentation\/cloudinary_video_player\">Cloudinary Video Player<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Intersection_Observer_API\">Intersection Observer API<\/a>\n<\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":28412,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[134,177,372,371,303,315],"class_list":["post-28411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-guest-post","tag-javascript","tag-nuxtjs","tag-under-review","tag-video","tag-vue"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Autoplay Video with Intersection Observer<\/title>\n<meta name=\"description\" content=\"This article explained how to autoplay a video using the intersection observer in nuxt.js and cloudinary to enhance user experience.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Autoplay Video with Intersection Observer\" \/>\n<meta property=\"og:description\" content=\"This article explained how to autoplay a video using the intersection observer in nuxt.js and cloudinary to enhance user experience.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-23T22:58:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-02T13:15:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692-jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"3840\" \/>\n\t<meta property=\"og:image:height\" content=\"2560\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Autoplay Video with Intersection Observer\",\"datePublished\":\"2022-03-23T22:58:11+00:00\",\"dateModified\":\"2025-03-02T13:15:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/\"},\"wordCount\":5,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA\",\"keywords\":[\"Guest Post\",\"Javascript\",\"NuxtJS\",\"Under Review\",\"Video\",\"Vue\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\",\"name\":\"Autoplay Video with Intersection Observer\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA\",\"datePublished\":\"2022-03-23T22:58:11+00:00\",\"dateModified\":\"2025-03-02T13:15:00+00:00\",\"description\":\"This article explained how to autoplay a video using the intersection observer in nuxt.js and cloudinary to enhance user experience.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA\",\"width\":3840,\"height\":2560},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Autoplay Video with Intersection Observer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Autoplay Video with Intersection Observer","description":"This article explained how to autoplay a video using the intersection observer in nuxt.js and cloudinary to enhance user experience.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js","og_locale":"en_US","og_type":"article","og_title":"Autoplay Video with Intersection Observer","og_description":"This article explained how to autoplay a video using the intersection observer in nuxt.js and cloudinary to enhance user experience.","og_url":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js","og_site_name":"Cloudinary Blog","article_published_time":"2022-03-23T22:58:11+00:00","article_modified_time":"2025-03-02T13:15:00+00:00","og_image":[{"width":3840,"height":2560,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692-jpg?_i=AA","type":"image\/jpeg"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/"},"author":{"name":"","@id":""},"headline":"Autoplay Video with Intersection Observer","datePublished":"2022-03-23T22:58:11+00:00","dateModified":"2025-03-02T13:15:00+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/"},"wordCount":5,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA","keywords":["Guest Post","Javascript","NuxtJS","Under Review","Video","Vue"],"inLanguage":"en-US","copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js\/","url":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js","name":"Autoplay Video with Intersection Observer","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA","datePublished":"2022-03-23T22:58:11+00:00","dateModified":"2025-03-02T13:15:00+00:00","description":"This article explained how to autoplay a video using the intersection observer in nuxt.js and cloudinary to enhance user experience.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA","width":3840,"height":2560},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/autoplay-video-with-intersection-observer-in-nuxt-js#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Autoplay Video with Intersection Observer"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681924582\/Web_Assets\/blog\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692\/269fd4de5adbd5ac013bb5a87d652a7f2361be4b-3840x2560-1_2841254692.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=28411"}],"version-history":[{"count":2,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28411\/revisions"}],"predecessor-version":[{"id":37057,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28411\/revisions\/37057"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/28412"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=28411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=28411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=28411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}