Safari中HTML5音频播放器上的“直播”消息 - Angular 6 Progressive Web App

时间:2018-05-15 07:04:05

标签: html5 angular audio broadcast live

我在Angular 6中有一个Progressive Web App,它包含一个音频HTML5标签来播放一些声音。我将其部署到Firebase。

我遇到的问题是Safari浏览器(移动和桌面,最新版本)。服务工作者以某种方式使其成为“直播”  尝试播放声音时(甚至在尝试单击播放按钮之前),渲染的音频标签上会显示消息。

我不会在Chrome中获得此“错误”,仅限于Safari。

我发布了一个示例应用,以便您可以看到问题(请记住  从Safari浏览器访问该应用程序。)

Example Firebase App

在此存储库中,您可以找到示例应用程序的代码。

Example App code repository

“直播”消息是这样的:Live Broadcast message in Safari

我需要用户可以播放音频,而无需在HTML5音频播放器上获得“直播”文字。我认为这与服务工作者配置有关,但我不确定。它也可能是一个角度问题。

任何帮助都会非常感激。

详情

版本:

Angular version: 6.0.1
angular/cli version: 6.0.1
Node version: 8.11.1
npm version: 5.6.0

构建我使用的应用 :(如果我不使用 - prod 选项,我不会收到“直播”消息,因为服务工作者不是  包括在你不使用它时)

 ng build --prod

app.component.html

<div height="300px;">
    <audio controls #audio123 controlsList="nodownload" 
        src="https://firebasestorage.googleapis.com/v0/b/angular-ng-build- 
        safari.appspot.com/o/-%20GIN%20-%20Testing%20Lakewood%20M31-CP%20(online-audio-converter.com).mp3?alt=media&token=1ba5f53e-58d3-43fe-b058-a6de05a51c29" preload="metadata">
    </audio>
</div>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

的package.json

{
  "name": "ng-build-sw-problem",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/pwa": "^0.6.1",
    "@angular/router": "^6.0.0",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26",
    "@angular/service-worker": "^6.0.0"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.0",
    "@angular-devkit/build-angular": "~0.6.1",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.1",
    "@angular/language-service": "^6.0.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}

NGSW-conf.json

{
  "index": "/index.html",
  "assetGroups": [{
    "name": "app",
    "installMode": "prefetch",
    "resources": {
      "files": [
        "/favicon.ico",
        "/index.html",
        "/*.css",
        "/*.js"
      ]
    }
  }, {
    "name": "assets",
    "installMode": "lazy",
    "updateMode": "prefetch",
    "resources": {
      "files": [
        "/assets/**"
      ]
    }
  }]
}

0 个答案:

没有答案