mediacontroller - Android media controller positioning -
i using media player , mediacontroller in activity play audio. in activity have image related audio , beneath description of audio. want mediacontroller displayed bottom of image , above description. @ present mediacontroller appears @ bottom of device if give image anchor view. there way can move mediacontroller above description
here go:
xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <videoview android:id="@+id/videoview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/blue" /> </linearlayout>
activity code:
package com.appsopmaat.bethgazo; import java.io.file; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import android.app.activity; import android.app.progressdialog; import android.content.context; import android.media.mediaplayer; import android.media.mediaplayer.oncompletionlistener; import android.media.mediaplayer.onerrorlistener; import android.media.mediaplayer.onpreparedlistener; import android.net.connectivitymanager; import android.net.networkinfo; import android.net.uri; import android.os.bundle; import android.os.environment; import android.widget.mediacontroller; import android.widget.toast; import android.widget.videoview; import com.loopj.android.http.asynchttpclient; import com.loopj.android.http.binaryhttpresponsehandler; public class player extends activity { videoview videoview; mediacontroller mediacontroller; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.player); videoview = (videoview) findviewbyid(r.id.videoview); mediacontroller = new mediacontroller(player.this); videoview.setmediacontroller(mediacontroller); videoview.setvideouri(uri.parse(mp3url)); videoview.start(); } } }); } videoview.setonerrorlistener(new onerrorlistener() { @override public boolean onerror(mediaplayer mp, int what, int extra) { // todo auto-generated method stub toast.maketext(player.this, "error please try again.", toast.length_long).show(); finish(); return true; } }); videoview.setonpreparedlistener(new onpreparedlistener() { @override public void onprepared(mediaplayer mp) { // todo auto-generated method stub mediacontroller.show(); } }); videoview.setoncompletionlistener(new oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { // todo auto-generated method stub finish(); } }); } }
Comments
Post a Comment