edge 的 video 标签无法播放来自URL.createObjectURL()创建的链接

body a 0 信誉分
2025-11-14T02:13:26.96+00:00

video 标签无法播放来自URL.createObjectURL()创建的链接。会显示视频已损坏图标。

Microsoft Edge | 音频和视频播放 | Android
0 个注释 无注释

1 个答案

排序依据: 非常有帮助
  1. Francisco Montilla 31,820 信誉分 独立顾问
    2025-11-14T02:50:07.88+00:00

    Hello,

    The most common cause in Edge is that the object URL is being revoked too early. If you call URL.revokeObjectURL right after assigning video.src, Edge may show the broken video icon because the decoder has not finished reading from the blob yet.

    Wrong pattern:

    const url = URL.createObjectURL(blob);
    video.src = url;
    URL.revokeObjectURL(url); // too early in Edge
    

    Correct pattern. Revoke only after the media is ready:

    const url = URL.createObjectURL(blob);
    video.src = url;
    video.addEventListener('loadeddata', () => {
      URL.revokeObjectURL(url);
    });
    

    If you attach sources dynamically, you can also wait for canplay or canplaythrough. As a quick test, simply remove the revoke line and reload. If the video plays, the timing was the issue.

    If this change does not help, tell me and I will walk you through the next fix.

    此答案是否有帮助?


你的答案

提问者可以将答案标记为“已接受”,审查方可以将答案标记为“已推荐”,这有助于用户了解答案是否解决了提问者的问题。