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

YouTube 是如何实现播放存储在浏览器 IndexedDB 中的多媒体文件的

  •  
  •   edis0n0 · 2022-08-23 13:23:47 +08:00 · 1079 次点击
    这是一个创建于 584 天前的主题,其中的信息可能已经有所发展或是发生改变。
    i.postimg.cc/Lsj78x65/Untitled.jpg

    Youtube 会员有个功能是离线缓存,把媒体存在浏览器 IndexedDB 中,这样用户不联网也能观看。看了下存储的是一堆 Uint8Array ,应该是媒体文件的二进制,想知道是怎么实现播放的,有实现类似功能的开源项目吗?
    okakuyang
        1
    okakuyang  
       2022-08-23 13:42:18 +08:00
    如果是浏览器支持的格式
    db.getitem(key)
    .then(blob=>URL.createObjectURL(new File([blob],"video.mp4",{type:"video/mp4"})))
    .then(url=>video.src=url)
    chnwillliu
        2
    chnwillliu  
       2022-08-24 05:03:09 +08:00 via Android
    Media source extension api
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2836 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:56 · PVG 20:56 · LAX 05:56 · JFK 08:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.