<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: sruthi</title>
    <description>The latest articles on Forem by sruthi (@sruthirose).</description>
    <link>https://forem.com/sruthirose</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1901978%2F83db3b30-acd0-4b9e-93b2-ea20bcd3c57a.jpg</url>
      <title>Forem: sruthi</title>
      <link>https://forem.com/sruthirose</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sruthirose"/>
    <language>en</language>
    <item>
      <title>Video autoplay is not working in mobile view</title>
      <dc:creator>sruthi</dc:creator>
      <pubDate>Thu, 08 Aug 2024 13:37:42 +0000</pubDate>
      <link>https://forem.com/sruthirose/video-autoplay-is-not-working-in-mobile-view-iif</link>
      <guid>https://forem.com/sruthirose/video-autoplay-is-not-working-in-mobile-view-iif</guid>
      <description>&lt;p&gt;i am creating a project in angular and typescript. i have a video in homepage which ,the client have requirement to play without interaction and even if the video goes out of window viewport it has to play. so i added an interval function in ts file like;&lt;/p&gt;

&lt;p&gt;ngAfterViewInit(): void {&lt;br&gt;
    const video = this.myVideo.nativeElement;&lt;br&gt;
    this.playCheckInterval = setInterval(() =&amp;gt; {&lt;br&gt;
      // console.log('Video element:', video.paused);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  if (video.paused) {
    video.play(); // Ensure the video keeps playing
  }
}, 250); // Check every second (adjust as needed)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;ngOnDestroy(): void {&lt;br&gt;
    if (this.playCheckInterval) {&lt;br&gt;
      clearInterval(this.playCheckInterval); // Clear the interval on component destroy&lt;br&gt;
    }&lt;br&gt;
  }&lt;br&gt;
html&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        &amp;lt;video #myVideo id="myVideo" style="width: 100%; height: auto;" class="video d-none d-md-block d-lg-block"
            preload="auto" autoplay [muted]="true" loop playsinline
            poster="https://ik.imagekit.io/7mkjuzyn8/assets/Academy/Redesign-Booking-Flow/vide-bg.jpg"
            controlsList="nofullscreen"&amp;gt;
            &amp;lt;source src="https://ik.imagekit/mia-desktop.mp4" type="video/mp4"&amp;gt;
            Your browser does not support the video tag.
        &amp;lt;/video&amp;gt;

        &amp;lt;video #myVideo id="myVideo" style="width: 100%; height: auto;" class="video d-block d-md-none d-lg-none"
            preload="auto" autoplay="autoplay" [muted]="true" loop="loop" playsinline poster=""
            controlsList="nofullscreen"&amp;gt;
            &amp;lt;source src="https://ik.imagekit/mia-mobile.mp4" type="video/mp4"&amp;gt;
            Your browser does not support the video tag.
        &amp;lt;/video&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;desktop it is playing but mobile is not auto playing. how can i achieve this?&lt;/p&gt;

</description>
      <category>angular</category>
    </item>
  </channel>
</rss>
