<?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>DEV Community: Morteza Z</title>
    <description>The latest articles on DEV Community by Morteza Z (@mort3za).</description>
    <link>https://dev.to/mort3za</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%2F223886%2Fe228ca2a-792d-4030-a161-da5f68b86415.jpeg</url>
      <title>DEV Community: Morteza Z</title>
      <link>https://dev.to/mort3za</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mort3za"/>
    <language>en</language>
    <item>
      <title>How to fix autoplay html5 video on iOS?</title>
      <dc:creator>Morteza Z</dc:creator>
      <pubDate>Thu, 17 Oct 2019 08:58:21 +0000</pubDate>
      <link>https://dev.to/mort3za/how-to-fix-autoplay-html5-video-on-ios-4p39</link>
      <guid>https://dev.to/mort3za/how-to-fix-autoplay-html5-video-on-ios-4p39</guid>
      <description>&lt;p&gt;If you have used Javascript to play an html5 video, you may encounter some errors, including this error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb1q9ijz4v1mggqr13nmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb1q9ijz4v1mggqr13nmh.png" alt="Unhandled Promise Rejection: AbortError: The operation was aborted."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or permission errors.&lt;/p&gt;

&lt;p&gt;The reason is that browsers in recent years changed their &lt;a href="https://webkit.org/blog/6784/new-video-policies-for-ios/" rel="noopener noreferrer"&gt;policies&lt;/a&gt; to prevent autoplay video because they think users don't want it (that's correct in most cases).&lt;/p&gt;

&lt;p&gt;What we can do to solve this issue?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;autoplay&lt;/code&gt;, &lt;code&gt;muted&lt;/code&gt; and &lt;code&gt;playsinline&lt;/code&gt; attributes to your &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element.&lt;/li&gt;
&lt;li&gt;If you need sound, you should put an unmute button beside the video, then in onClick callback, get video element and set &lt;code&gt;muted = false&lt;/code&gt; by Javascript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip!&lt;/strong&gt; If you have multiple videos on your page and only a single unmute button, then make sure to unmute all videos in the click callback of that button, otherwise, iOS won't let you unmute video before playing it on demand.&lt;/p&gt;

&lt;p&gt;That's it, happy autoplaying!&lt;/p&gt;

</description>
      <category>html</category>
      <category>video</category>
      <category>autoplay</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
