Sai Kiran Sai Kiran - 7 months ago 803
Android Question

Should have subtitle controller already set Mediaplayer error Android

When ever i play a media it shows a warning in DDMS

Should have subtitle controller already set


private void start() {

mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {


Should have subtitle controller already set

info/warning (2, 0)

When i search on Google not even a single topic related to it, How can i get rid or disable this ?


A developer recently added subtitle support to VideoView.

When the MediaPlayer starts playing a music (or other source), it checks if there is a SubtitleController and shows this message if it's not set. It doesn't seem to care about if the source you want to play is a music or video. Not sure why he did that.

Short answer: Don't care about this "Exception".

Edit :

Still present in Lollipop,

If MediaPlayer is only used to play audio files and you really want to remove these errors in the logcat, the code bellow set an empty SubtitleController to the MediaPlayer.

It should not be used in production environment and may have some side effects.

static MediaPlayer getMediaPlayer(Context context){

    MediaPlayer mediaplayer = new MediaPlayer();

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
        return mediaplayer;

    try {
        Class<?> cMediaTimeProvider = Class.forName( "" );
        Class<?> cSubtitleController = Class.forName( "" );
        Class<?> iSubtitleControllerAnchor = Class.forName( "$Anchor" );
        Class<?> iSubtitleControllerListener = Class.forName( "$Listener" );

        Constructor constructor = cSubtitleController.getConstructor(new Class[]{Context.class, cMediaTimeProvider, iSubtitleControllerListener});

        Object subtitleInstance = constructor.newInstance(context, null, null);

        Field f = cSubtitleController.getDeclaredField("mHandler");

        try {
            f.set(subtitleInstance, new Handler());
        catch (IllegalAccessException e) {return mediaplayer;}
        finally {

        Method setsubtitleanchor = mediaplayer.getClass().getMethod("setSubtitleAnchor", cSubtitleController, iSubtitleControllerAnchor);

        setsubtitleanchor.invoke(mediaplayer, subtitleInstance, null);
        //Log.e("", "subtitle is setted :p");
    } catch (Exception e) {}

    return mediaplayer;

This code is trying to do the following from the hidden API

SubtitleController sc = new SubtitleController(context, null, null);
sc.mHandler = new Handler();
mediaplayer.setSubtitleAnchor(sc, null)