3

I have a Progressive Web App in Angular 6 that includes an audio HTML5 tag to play some sounds. I deploy it to Firebase.

The problem I have is in Safari Browser (Mobile and Desktop, latest versions). Somehow the Service Worker makes that a "Live Broadcast" message appears on the rendered audio tag when you try to play the sound (or even before you try to click on play button).

I don't get this "error" in Chrome, only in Safari.

I published an example app so that you can see the problem (remember to visit the app from a Safari browser).

Example Firebase App

In this repository you can find the code of the example app.

Example App code repository

The "Live broadcast" message is something like this: Live Broadcast message in Safari

I need that users can play the audio without getting that "Live Broadcast" text on the HTML5 audio player. I think it is something related with the Service Worker configuration, I'm not sure though. It might be an Angular problem too.

Any help would be really appreciated.

Details

Versions:

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

To build the app I use: (If I don't use --prod option I don't get the "Live Broadcast" message because the service worker is not included when you don't use it)

 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/**"
      ]
    }
  }]
}
Daniel Muñoz
  • 1,374
  • 12
  • 18
  • Seems related: https://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not – Ryan Feb 17 '19 at 21:10

0 Answers0