【问题标题】:Not work video and audios on safari - NodeJS - angular4无法在 safari 上播放视频和音频 - NodeJS - angular4
【发布时间】:2018-02-09 21:21:31
【问题描述】:

我有一个应用程序,我可以在其中展示一些图像、视频和音频。 图像效果很好,但音频和视频有问题。

节点 API:

    let config = new Config(),
    client = config.Storage
    export default class ImageCtrl {
        product = (req, res, next) => {
            var params = req.params,
                point = params.filename.lastIndexOf('.'),
                nameFile = params.filename.slice(0, point),
                ext = params.filename.slice(point);
            res.writeHead(200, {
                'Cache-Control': 'no-cache'
            });
            let remote = `${nameFile}-thumb${ext}`;
            if (nameFile.includes('audio')) {
                remote = `${nameFile}${ext}`
            }
            client.download({
                container: 'Multimedia',
                remote: remote
            }, function(err, result) {
                // handle the download result
            }).pipe(res);
        }
    }

config.ts

export default class Config {
   Storage: any = pkgcloud.storage.createClient(config);
}

Angular4-HTML5

<video width="100%" *ngIf="product.mediacategory === 'video'" controls preload="none" [poster]="'/api/image/products/' + product._id + '-video.png'" controlsList="nodownload">
    <source [src]="/api/image/products/5a69b1b32e4be51cb82a7659-video.webm" type="video/webm">
    <source [src]="/api/image/products/5a69b1b32e4be51cb82a7659-video.mp4" type="video/mp4">
    <source [src]="/api/image/products/5a69b1b32e4be51cb82a7659-video.ogv'" type="video/ogv">
  </video>

音频和图像是相同的 API,但仅适用于 safari 图像。在 chrome 和 firefox 中,音频、视频和图像都可以正常工作。

在 Safari 中它看起来像这样:

在铬:

----如果我删除 [src] 的 [],它在 chrome 上不起作用。-----

【问题讨论】:

标签: javascript node.js html angular video


【解决方案1】:

iOS 上的 Safari 支持低复杂度的 AAC 音频、MP3 音频、AIF 音频、WAVE 音频和基线配置文件 MPEG-4 视频。桌面版 Safari(Mac OS X 和 Windows)支持已安装的 QuickTime 版本支持的所有媒体,包括任何已安装的第三方编解码器 click here for reference

【讨论】:

  • 我尝试了这个选项,它适用于例如这个 URL techslides.com/demos/sample-videos/small.mp4 但我的节点 URL 不是
  • 从 src 中删除方括号。像这样 src="/api/image/products/5a69b1b32e4be51cb82a7659-video.webm"。如果你给 [src] 的意思,你必须提到变量
  • 你用inspect检查了输出,控制台有没有错误??否则视频的链接是否正确??
  • 我没有报错,只有当我点击“播放按钮”时 Unhandled Promise Rejection: [object DOMError]
  • stackoverflow.com/questions/45311263/… 我认为这个答案会对你有所帮助..
猜你喜欢
  • 1970-01-01
  • 2012-07-26
  • 2020-02-10
  • 1970-01-01
  • 2022-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-25
相关资源
最近更新 更多