Android videoview mediacontroller pause or play button

馋奶兔 提交于 2019-12-23 03:49:14

问题


My video works fine but i cant controll it. I cant see play or pause button.i need play or pause button .mediaController not working fine. i using this codes

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.Display;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;

public class avid extends Activity
{
    private String path = "http://techslides.com/demos/sample-videos/small.mp4";
    private VideoView video_view_;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.avid);
        video_view_ = (VideoView)findViewById(R.id.surface_view);
        MediaController mediaController=new MediaController(this);
        mediaController.setAnchorView(video_view_);
        video_view_.setMediaController(mediaController);
        video_view_.setVideoURI(Uri.parse(path));
        video_view_.start();
    }
}

layout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <VideoView
        android:id="@+id/surface_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        />
</FrameLayout>

i see only video . i need play or pause button here is picture enter link description here


回答1:


you can put the media controller directly in the main xml file like this :

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

and normaly, when the video start, you can see the media controller.



来源:https://stackoverflow.com/questions/21151529/android-videoview-mediacontroller-pause-or-play-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!