mediacontroller

Make MediaController show without hide

限于喜欢 提交于 2019-12-03 16:31:16
I try to use MediaController to play music. I want the MediaController appear until the "back" button is pressed. Now I have try below code: MediaController mediaController = new MediaController(this){ @Override public void setMediaPlayer(MediaPlayerControl player) { super.setMediaPlayer(player); this.show(); } @Override public void show(int timeout) { super.show(0); } //instead of press twice with press once "back" button to back @Override public boolean dispatchKeyEvent(KeyEvent event) { if(event.getKeyCode() == KeyEvent.KEYCODE_BACK) { Activity a = (Activity)getContext(); a.finish(); }

How to re-position the MediaController?

孤人 提交于 2019-12-03 15:43:53
问题 I have been using mediaController for my app. By default, the Media Controller is displayed at the bottom of the screen. Is there a way to display the Media Controller in the middle of the screen instead? 回答1: Placing the mediacontroller only works if the video size is known. Thus you'll have to do: video.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() { @Override public void

MediaController always show on Android

拜拜、爱过 提交于 2019-12-03 14:56:44
问题 I am using mediacontroller in my app, but it shows only for 3 seconds. I have searched a lot, but in every document I see only the show function, set time out, but it has no effect. How can I always show mediacontroller? I have tested show(0) , but it had no effect. 回答1: You can extend the MediaController class and programmatically set an instance of it to a VideoView class: import android.content.Context; import android.util.AttributeSet; import android.widget.MediaController; public class

MediaController Positioning - bind to VideoView

核能气质少年 提交于 2019-12-03 12:05:57
There have been a lot of discussions about how to position a MediaController and most answers are to use the setAnchorView -Method. At the first glance this solution seems to work but in my case it doesn't. According to this Post setAnchorView only acts as a reference for initial positioning of the MediaController , but actually creates a new floating Window on top. So what I want is a MediaController that is really bound to a parent View (e.g. VideoView). For example if you have a LinearLayout within a ScrollView and you have to scroll down to your VideoView where the MediaController is

MediaController always show on Android

懵懂的女人 提交于 2019-12-03 04:39:02
I am using mediacontroller in my app, but it shows only for 3 seconds. I have searched a lot, but in every document I see only the show function, set time out, but it has no effect. How can I always show mediacontroller? I have tested show(0) , but it had no effect. You can extend the MediaController class and programmatically set an instance of it to a VideoView class: import android.content.Context; import android.util.AttributeSet; import android.widget.MediaController; public class MyMediaController extends MediaController { public MyMediaController(Context context, AttributeSet attrs) {

android: hiding media controller functions

廉价感情. 提交于 2019-12-02 02:34:34
问题 I have a videoview and when the video starts, the media controller is shown for 3 seconds. I want to hide the media controller unless i tap on the screen. I tried MediaController mc= new MediaController(); mc.hide(); Videoview.setMediaController(mc); .. .. .. But it didn't work.. Any suggestions please? 回答1: This isn't really a solution to hiding the MediaController, but if you want to get rid of the thing altogether, do this: videoView.setMediaController(null); You can have it initially

MediaController doesn't work

爱⌒轻易说出口 提交于 2019-12-02 02:33:19
问题 My layout that contains videoView <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" > <ImageView android:id="@+id/imgv_image" android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/app_name" android:scaleType="centerCrop" android:visibility="invisible" /> <VideoView android:id="@+id/videoview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout

MediaController doesn't work

社会主义新天地 提交于 2019-12-02 01:46:15
My layout that contains videoView <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" > <ImageView android:id="@+id/imgv_image" android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/app_name" android:scaleType="centerCrop" android:visibility="invisible" /> <VideoView android:id="@+id/videoview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_marginBottom="20dp" android:layout_alignParentLeft="true" android

android: hiding media controller functions

匆匆过客 提交于 2019-12-02 00:49:25
I have a videoview and when the video starts, the media controller is shown for 3 seconds. I want to hide the media controller unless i tap on the screen. I tried MediaController mc= new MediaController(); mc.hide(); Videoview.setMediaController(mc); .. .. .. But it didn't work.. Any suggestions please? This isn't really a solution to hiding the MediaController, but if you want to get rid of the thing altogether, do this: videoView.setMediaController(null); You can have it initially hidden by doing the above, and then when you want it to show (onClick or onTouch or whatever), just make a new

关于对Android的videoView和mediaController的吐槽

末鹿安然 提交于 2019-12-01 11:23:33
这几天在做视频播放器一直在研究videoview。 videoview是和video连用的。2个组件分别都提供一 个方法关联另一方: mediaController-setAnchorView( videoview ),videoview-setMediaController( mediaController )。 我习惯在一个布局文件中设置好videoview的位置之后,在activity的onCreate()中将mediaController 动态初始化并关联到已经设置好的videoview上。 但是这里的说明下在布局中设置videoview的时候最好给videoview外面单独套一个的容器。 当然这个外层容器的高度要设定为wrap_content。这样就会把视频播放器和控制器很好的组合在一起。 这里我用的是线性布局LinearLayout因为我不想控制器把视频给遮盖住了。 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/main_videoview_contianer"> <VideoView android:id="@+id/videoView"