V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
edis0n0
V2EX  ›  程序员

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

  •  
  •   edis0n0 · Aug 23, 2022 · 1530 views
    This topic created in 1345 days ago, the information mentioned may be changed or developed.
    i.postimg.cc/Lsj78x65/Untitled.jpg

    Youtube 会员有个功能是离线缓存,把媒体存在浏览器 IndexedDB 中,这样用户不联网也能观看。看了下存储的是一堆 Uint8Array ,应该是媒体文件的二进制,想知道是怎么实现播放的,有实现类似功能的开源项目吗?
    okakuyang
        1
    okakuyang  
       Aug 23, 2022
    如果是浏览器支持的格式
    db.getitem(key)
    .then(blob=>URL.createObjectURL(new File([blob],"video.mp4",{type:"video/mp4"})))
    .then(url=>video.src=url)
    chnwillliu
        2
    chnwillliu  
       Aug 24, 2022 via Android
    Media source extension api
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3460 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:23 · PVG 12:23 · LAX 21:23 · JFK 00:23
    ♥ Do have faith in what you're doing.