音频播放完毕后通知 [英] notify once the audio is finished playing

查看:99
本文介绍了音频播放完毕后通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在尝试实现语音记录的基本功能,例如

Well i am trying to implement basic functionality of voice recording , like

记录,播放/暂停,停止

Record , play/pause , stop

我能够完成所有这些操作,但是唯一的问题是音频完成后如何通知我玩.我的意思是,如果我播放音频文件,则一旦播放完毕,我想通知它现在已停止.

i am able to do all of them but the only issue is how can i get notified once the audio gets finished playing. I mean if i play an audio file then once it gets finished playing i want a notification that it is stopped now.

到目前为止我已经用过

   mPlayer.start() // to start the audio

   mPlayer.stop(); // to stop the audio

   mPlayer.pause(); //to pause the audio

我只是想找出音频文件自动完成播放后我怎么知道

i am just trying to find out how would i know once the audio file automatically finished playing

推荐答案

您可以使用Media Player类的完成侦听器"来执行此操作.

You can use the Completion Listener of Media Player class to do this.

mediaPlayer.setOnCompletionListener(new OnCompletionListener() {

            public void onCompletion(MediaPlayer mp) {

                Log.i("Completion Listener","Song Complete");
                Toast.makeText(context, "Media Completed", Toast.LENGTH_SHORT).show();
            }
        });

这篇关于音频播放完毕后通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆