Android VideoView MediaController暂停或播放按钮 [英] Android videoview mediacontroller pause or play button

查看:933
本文介绍了Android VideoView MediaController暂停或播放按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的视频工作正常,但我无法控制它.我看不到播放或暂停按钮.我需要播放或暂停按钮.mediaController无法正常工作.我使用此代码

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();
    }
}

布局

<?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

推荐答案

您可以将媒体控制器直接放置在主xml文件中,如下所示:

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.

这篇关于Android VideoView MediaController暂停或播放按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆