[英]Ionic- How to play only one media object from multiple objects
There are three Ionic-native media objects in the screen. 屏幕上有三个Ionic-native媒体对象。 I make a code that play the selected one.
我编写了一个播放所选代码的代码。
play(filename)
{
this.curr_playing_file = this.createAudioFile(savfilename);
this.curr_playing_file.play();
}
createAudioFile(filename): MediaObject {
if (this.platform.is('ios')) { //ios
console.log(filename.replace(/^file:\/\//, ''));
return this.media.create(filename.replace(/^file:\/\//, ''));
} else { // android
return this.media.create(filename);
}
}
when i click three of them , they are playing at the same time. 当我单击其中三个时,它们会同时播放。 I want to play only one at that time.
当时我只想玩一场。 Please help how can i solve this problem efficiently.
请帮助我如何有效解决此问题。 Thanks.
谢谢。
First you have to check if any other audio is playing and if any other audio is playing you need to stop it and release it before playing the other file 首先,您必须检查是否正在播放其他音频,是否正在播放其他音频,则需要先停止播放并释放它,然后再播放其他文件
if (this.curr_playing_file.mediaStatus == 2)
{
this.curr_playing_file.stop();
this.curr_playing_file.Release();
}
this.media.create(filename);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.