androidxmlmediacontroller

use the android MediaController in xml layout


When I go to the main.xml file and add MediaController to the layout, I have only these options:

    <MediaController
    android:id="@+id/mediaController1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

There is no value to put the sound path in it all the tutorials show how to do it in the code and not the xml, and I learned xml is better m I missing somethin? I already have a sound in the project folders.

Eclipse, android API level 3, fedora linux 16.


Solution

  • Sounds like you're missing a rather large piece of the puzzle. The MediaController isn't concerned with the path to the media you want to play. That's something you would supply to the MediaPlayer class, which you would then associate with your MediaController by using the setMediaPlayer method.

    http://developer.android.com/reference/android/widget/MediaController.html#setMediaPlayer(android.widget.MediaController.MediaPlayerControl)

    To make a long story short, you're not going to be able to play media using nothing but XML.