Hi guys,
I've been unable to successfully hookup a MediaController to an audio
MediaPlayer. I've successfully created a MediaPlayer to play audio.
And i've also programatically instantiated a MediaController.
MediaPlayer mp = myclass.getMediaPlayer(); //My custom class that
returns the current media player
MediaController mc = new MediaController(this);
mc.setAnchorView(button);
mc.setEnabled(true);
mc.show(2000); //does not crash if i comment this out
I have 2 big problems:
1. The above code crashes unless I comment out the show. In which case
the controller does not appear.
I have debugged mp and mc and the button are all not null values, but
I still get the following in logcat:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.test.android.test.activity.testActivity}:
java.lang.NullPointerException
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2496)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at
android.widget.MediaController.disableUnsupportedButtons(MediaController.java:
258)
at android.widget.MediaController.show(MediaController.java:288)
at
com.test.android.test.activity.testActivity.onCreate(testActivity.java:
105)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2459)
... 11 more
2. The other problem is that I cannot see a way to hookup the
MediaController to Mediaplayer as setMediaPlayer does not take
MediaPlayer as the paramater.
A simple example of a MediaController working with mp3's would be all
that I need!
Thanks alot for your time.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en