【问题标题】:ionic 3 audio livestreaming is slower than the live radio station streamingionic 3 音频直播比广播电台直播慢
【发布时间】:2018-02-12 02:00:02
【问题描述】:

我正在使用 ionic3 开发一个电台移动应用程序,在使用 ionic3 中的 StreamingMedia 插件集成直播后,比电台主流慢 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();
};

}

appComponent.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();
  }
}

【问题讨论】:

  • 你能展示一些你的code吗?
  • radio.ts 导出类 RadioPlayer { url:string;流:任何;承诺:任何;构造函数() { this.url = "/*9"; this.stream = new Audio(this.url); };播放() { this.stream.play(); this.promise = new Promise((resolve,reject) => { this.stream.addEventListener('playing', () => { resolve(true); }); this.stream.addEventListener('error', () => { 拒绝(假); }); });返回 this.promise; }; pause() { this.stream.pause(); }; }
  • 你能看懂吗?请使用code 格式将其放入您的问题中?
  • 对不起,上面的代码
  • 你在用这个插件吗?:ionicframework.com/docs/native/streaming-media

标签: angular typescript ionic2 cordova-plugins ionic3


【解决方案1】:

我想建议使用Native Streaming Media 插件。因为它是原生的,希望你的缓慢消失。

此插件允许您全屏流式传输音频和视频, iOS 和 Android 上的原生播放器。

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

Git Repo

【讨论】:

  • 不工作,请你帮我提供一个示例代码
  • 现在正在工作,我禁用了方向:'false',但在 android 上不起作用
  • 我想要的音频流不是全屏的,当我在流媒体插件中禁用全屏时不起作用。请任何帮助
猜你喜欢
  • 1970-01-01
  • 2022-01-27
  • 1970-01-01
  • 2019-05-10
  • 2011-04-21
  • 1970-01-01
  • 2015-03-05
  • 2013-06-03
  • 1970-01-01
相关资源
最近更新 更多