Ionic media streaming
Ionic media streaming
am having challenges implementing an audio API from shoutcast, currently working on a streaming radio app using Ionic. It refuses to play the audio when i stream using the audio API from shoutcase.
any help on this please? thanks
//playerservice
import Injectable from '@angular/core';
import Media, MediaObject from '@ionic-native/media';
import LoadingController, Platform from 'ionic-angular';
@Injectable()
export class PlayerServiceProvider
// This controls the alternating play and pause images and function
play: boolean = true;
// Property “radio” for the instance of the MediaObject for the Media plugin
radio: MediaObject
constructor(private media: Media, private platform: Platform, public loadingCtrl: LoadingController)
this.platform.ready().then(() =>
this.radio = this.media.create('http://yp.shoutcast.com/sbin/tunein-station.m3u?id=862132'); // Insert your own stream URL here.
this.radio.play();
);
// Function to play the audio stream
playAudio()
//Loading Spinner Configuration
const loading = this.loadingCtrl.create(
content: 'Loading stream...',
spinner: 'crescent',
showBackdrop: false,
cssClass: 'spin' // This class is defined in the app.scss file
);
loading.present();
setTimeout(() =>
loading.dismiss();
, 4000);
//End of Loading Spinner Configuration
// This controls the alternating play and pause images and function
this.play = false;
// Function to stop the audio stream
stopAudio()
this.radio.stop();
// This controls the alternating play and pause images and function
this.play = true;
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
u can try this it support streaming media --> ionicframework.com/docs/native/streaming-media
– Hitmacreed
Aug 22 at 10:39