V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wohefengyiyang
V2EX  ›  iOS

关于 ios 低电量模式浏览器如何自动播放<video>

  •  
  •   wohefengyiyang · 133 天前 · 842 次点击
    这是一个创建于 133 天前的主题,其中的信息可能已经有所发展或是发生改变。
    ios 低电量模式下无法自动播放<video>标签的视频,然后我想着用 js 脚本模拟用户点击,发现还是无法播放,滑动屏幕时会开始播放了。 但是这种情况下,进去页面的时候视频上方的那个播放按钮很丑陋,请问一下,有没有什么办法去除?如果能直接低电量模式自动播放就更好了
    <div class="content-video-mob newmob_vid">
    <video autoplay playsinline muted loop id="mobile-Video">
    <source src="<?php echo get_site_url(); ?>xxxx.mp4" type="video/mp4" />
    </video>
    </div>
    2 条回复    2023-12-18 01:39:36 +08:00
    justin2018
        1
    justin2018  
       133 天前
    试一试这个 但是视频会没有声音

    ```
    const video = document.querySelector("video");

    if (!video) return;

    const promise = video.play();
    if (promise !== undefined) {
    promise.then(() => {
    // Autoplay started
    }).catch(error => {
    // Autoplay was prevented.
    video.muted = true;
    video.play();
    });
    }
    ```
    wohefengyiyang
        2
    wohefengyiyang  
    OP
       132 天前
    @justin2018 这个不行的,我之前试过了,ios 低电量模式下会阻止,必须要用户与屏幕有交互。。。我看了滴滴的一个做法,是把视频分割成图像帧了,然后轮流播放。。但是巨卡。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3593 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:37 · PVG 12:37 · LAX 21:37 · JFK 00:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.