Capacitor-plugin-playlist:在带有 Ionic 5 的 Android 上没有音频

发布时间:2021-03-04 14:08

问)我已经安装并构建了这个插件,但是当我尝试加载下面示例中的硬编码 mp3 时没有声音,有什么想法吗?

  • 插件:https://github.com/phiamo/capacitor-plugin-playlist
  • AudioProvider 是该存储库中的示例文件。
  • 我的示例播放器类:
import { Component, OnInit } from '@angular/core';
import { AudioProvider } from '../Services/AudioProvider';


@Component({
  selector: 'app-player',
  templateUrl: 'player.page.html',
  styleUrls: ['player.page.scss'],
})
export class PlayerPage implements OnInit {

  public isPlaying: boolean = false;
  public audioTrack: any;

  constructor(
    public _AudioProvider: AudioProvider
  ) {
  }

  ngOnInit() {
    this.audioTrack = {
      isStream: true,
      assetUrl: "https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3",
      artist: 'Whatever Artist',
      album: 'No Album',
      title: "Some title"
    };

    this._AudioProvider.init().then(() => {
      this._AudioProvider.addItem(this.audioTrack);
    });
  }

  play() {
    this._AudioProvider.play();
    this.isPlaying = this._AudioProvider.isPlaying;
  }


}

谢谢!

我的系统设置::

Ionic:

   Ionic CLI                     : 6.13.1 (/Users/daveshirman/.nvm/versions/node/v15.10.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.5.5
   @angular-devkit/build-angular : 0.1101.4
   @angular-devkit/schematics    : not installed
   @angular/cli                  : 11.1.4
   @ionic/angular-toolkit        : 3.1.0

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res                          : 0.15.3
   native-run (update available: 1.3.0) : 0.2.8

System:

   NodeJS : v15.10.0 (/Users/daveshirman/.nvm/versions/node/v15.10.0/bin/node)
   npm    : 7.5.3
   OS     : macOS Big Sur
回答1