我正在开发一个带有Ionic3的无线电台移动应用程序,在使用Ionic3中的流媒体插件集成Livestreaming之后,速度比无线电台主流慢了1分钟,请问有什么帮助吗?
收音机.ts

 export class RadioPlayer {
  url:string;
  stream:any;
  promise:any;
   constructor() {
   this.url = "http://104.247.79.188:8000/kfm";
   this.stream = new Audio(this.url);
 };
 play() {
   this.stream.play();
   this.promise = new Promise((resolve,reject) => {
     this.stream.addEventListener('playing', () => {
       resolve(true);
     });
    this.stream.addEventListener('error', () => {
       reject(false);
     });
   });
  return this.promise;
};
pause() {
  this.stream.pause();
};

}

应用组件.ts
 import { Component, ViewChild } from '@angular/core';
 import { Platform, MenuController, Nav } from 'ionic-angular';
 import {RadioPlayer} from './radio/radio';
    @Component({
  templateUrl: 'app.html',
  providers: [RadioPlayer]
})
export class MyApp {
  constructor(player: RadioPlayer)
{
    this.player = player;
    this.play();
 }
 play() {
    this.player.play().then(() => {
      console.log('Playing');
    });
  }
  pause() {
    this.player.pause();
  }
}

最佳答案

我建议使用Native Streaming Media插件,因为它是本机的,希望你的慢度会消失。
这个插件允许你在全屏上播放音频和视频,
iOS和Android上的本地播放器。

ionic cordova plugin add cordova-plugin-streaming-media
npm install --save @ionic-native/streaming-media

Git Repo

09-27 05:26