GPlayer chrome 扩展 - 添加视频播放

问题描述

有些人可能已经注意到,GMail CSP 不再允许播放音频或视频文件。起初它影响了 Chromium 浏览器,但即使是 Firefox 也不再允许它。所以我制作了一个 Google Chrome 扩展来播放 mp3 和 wavs(我的主要用例)。有人要求添加视频播放,但我无法绕过 CSP 限制。

我试过XMLHttpRequest's arrayBuffer

const request = new XMLHttpRequest();
request.open('GET',url,true);
request.responseType = 'arraybuffer';
...
request.onload = () => {
  const { readyState,status,response } = request;
  const videoHtml = location.appendChild(document.createElement("video"));
  videoHtml.classList.add("videoPlayer");
  const mediaSource = new MediaSource();
  videoHtml.src = URL.createObjectURL(mediaSource);
  mediaSource.addEventListener("sourceopen",(e) => {
    URL.revokeObjectURL(videoHtml.src);
    const sourceBuffer = mediaSource.addSourceBuffer("video/mp4");
    console.log("appending Buffer to sourceBuffer");
    sourceBuffer.addEventListener("updateend",(e) => {
      if (!sourceBuffer.updating && mediaSource.readyState === "open") mediaSource.endOfStream();
    });
    sourceBuffer.appendBuffer(response);
  });
request.send();

我也试过XMLHttpRequest's blob

const request = new XMLHttpRequest();
request.open('GET',true);
request.responseType = 'blob';
...
request.onload = () => {
  const { readyState,response } = request;
  const videoHtml = location.appendChild(document.createElement("video"));
  videoHtml.classList.add("videoPlayer");
  videoHtml.src = URL.createObjectURL(response);
request.send();

都失败了 Refused to load media from ...because it violates the following Content Security Policy directive: "media-src https://*.googlevideo.com/videoplayback/"

我如何才能绕过 GMail 播放视频的错误 CSP?

Chrome 扩展程序 - https://chrome.google.com/webstore/detail/gplayer/obdmmgdlafadeehmbmcmoggnaokehnaj

Github 链接 - https://github.com/TriStarGod/GPlayer

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...