0

Alright so i'm trying to create a mediacontroller to control my audio file that plays whenever i click on an imageview. i tried this but it wouldn't recognized the audio file (mysound)

    MediaController mc = new MediaController(this);
    mc.setMediaPlayer(mysound);
    mysound.setMediaController(mc);
user2192418
  • 49
  • 1
  • 5

1 Answers1

0

You should be able to call start per the Android documentation once you have provided a valid audio file.

MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.sound_file_1);
mediaPlayer.start(); // no need to call prepare(); create() does that for you
Aaron McIver
  • 24,527
  • 5
  • 59
  • 88
  • yes i put mysound.start(); and it plays but i want to add a media controller – user2192418 Jun 19 '13 at 17:10
  • Have you called setAnchorView? _The MediaController will create a default set of controls and put them in a window floating above your application. Specifically, the controls will float above the view specified with setAnchorView(). The window will disappear if left idle for three seconds and reappear when the user touches the anchor view._ – Aaron McIver Jun 19 '13 at 18:15