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

Is possible to stop audio stream?

$
0
0

Is possible to stop the download stream on Ionic?

i have this function

export class RadioPlayer {
    url: string;
    stream: any;
    promise: any;

    constructor() {
    };

    play() {
        this.url = "http://109.168.100.173:8058/;stream.mp3";
        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', () => {
                reject(false);
            });
        });
        return this.promise;
    };

    pause() {
        if (this.stream != null) {
            this.stream.pause();


        }
        this.stream = null;
    }

    stop() {
        if (this.stream != null) {
            this.stream.pause();
            this.url = "";
        }
        this.stream = null;
    }

}

If i click on play it works but if i click on stop the device continue download of streaming.

is possible to stop the download of streaming?

Thank You


Viewing all articles
Browse latest Browse all 229617

Trending Articles



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