离子流媒体插件问题

时间:2017-06-05 14:23:20

标签: ionic-framework ionic3

我正在尝试构建一个离子应用来传输音频源。

这是我到目前为止所拥有的......

app.module.ts

    <?php

    // check if the repeater field has rows of data

    $feature_posts = the_sub_field('feature_image_post');

    if( have_rows('repeat_field') ):

      // loop through the rows of data
        while ( have_rows('repeat_field') ) : the_row();

            // display a sub field value
              echo '<div style="float:left">';
                the_sub_field('restaurant_name');
              echo '</div>';
              echo '<div style="float:left">';
                the_sub_field('restaurant_state');
              echo '</div>';

              echo '<div style="float:left">';
                the_sub_field('restaurant_image_post');
               echo '</div>';  

                  if (empty($feature_posts)) {
                    echo '<div style="display:none">';
                    the_sub_field('feature_image_post');
                    echo '</div>'; 
                  } 

                  else {

                      the_sub_field('feature_image_post');
                  }

        endwhile;

    else :

        // no rows found

    endif;

    ?>

home.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { StreamingMedia } from '@ionic-native/streaming-media';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    StreamingMedia,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

home.html的

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { StreamingMedia, StreamingAudioOptions } from '@ionic-native/streaming-media';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private streamingMedia: StreamingMedia) {

  }

    playStream() {

        let options: StreamingAudioOptions = {
            bgColor: 'red',
            successCallback: () => { console.log('Audio played') },
            errorCallback: (e) => { console.log('Error streaming') }
        };

        this.streamingMedia.playAudio('http://listen.radionomy.com:80/NewYorkClassicRock');

    }

}

使用离子视图,单击按钮在android或ios中不执行任何操作。

我做错了什么或错过了什么?

谢谢!

2 个答案:

答案 0 :(得分:1)

它在离子视图中不起作用。 使用以下命令在物理设备上运行它:

cordova运行android --debug

来自你的app文件夹!

答案 1 :(得分:1)

一个小观察,您正在设置选项,但没有将其传递给streamingMedia。您可能要这样做:

this.streamingMedia.playAudio('http://listen.radionomy.com:80/NewYorkClassicRock',options);