Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229600

Radio player with shoutcast ip

$
0
0

AppComponent.ts

 this.events.subscribe('play', () => {
      
      this.player.play('http://streaming.livecenter.com.br:9322/;stream.mp3').then(() => {
        console.log('Playing');
      });
      this.storage.set('button', 'play');
      
    });

    this.events.subscribe('stop', () => {
      this.player.pause();
      this.storage.set('button', 'stop');
      console.log('STOP')
      
    });

player.ts

 play(streamUrl) {
    try {
      let src = streamUrl + '/;stream.mp3';
      this.stream = new Audio(src);
      this.stream.play();
      this.promise = new Promise((resolve, reject) => {
        this.stream.addEventListener('playing', () => {
          resolve(true);
        });

        this.stream.addEventListener('error', () => {
          reject(false);
        });
      });
      return this.promise;  
    } catch (error) {
      console.log("erro ao carregar a playlist");
    }
    
  };

  pause() {
    if (this.stream != null) {
      this.stream.pause();
      this.stream.currentTime = 0;
      this.stream.src = "";  
    }
  };

Viewing all articles
Browse latest Browse all 229600

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>