0

i want to play sound either using mediaplayer or sound pool. and i want to do something when my sound/music reach some position such as

function void hello(){ // you reach position 1.5 seconds }  

mediaplayer.setOnCertainPosition(1500, hello()); // not actual code

currently what i found is create loop function for every xxx millisecond and do

mediaplayer.getCurrentPosition()

from this answer

is there any better code?
note: i found about audiotrack but not sure how it works and how to use it

Community
  • 1
  • 1
gondai yosuke
  • 599
  • 2
  • 5
  • 19
  • If I was doing this I would use a timer that starts the same time of the media player, that would fire ontick every 1.5 second. Whether that is the a better solution is another question – Phil3992 Mar 28 '17 at 13:50
  • If you don't want to set a timer, you could just check the volume when the volume changes by setting an observer, as specified in this http://stackoverflow.com/questions/6896746/is-there-a-broadcast-action-for-volume-changes – sai Mar 28 '17 at 14:02
  • @Phil3992 my trigger time is not "every xx seconds" but at certain time like 1s, 9s, 15s, etc.. TheManHasNoName the trigger from timer not volume, but its like that code implement broadcasting when something happen on audio manager – gondai yosuke Mar 29 '17 at 06:57

0 Answers0