Mediacontroller无法全屏播放视频

时间:2019-07-08 05:38:13

标签: android android-videoview

我想拥有全屏视频视图,并通过在.xml中使用相对布局并在相应的.java类中正常播放视频来成功实现了该视图。但是媒体控制器没有出现。有人可以告诉我我要去哪里了吗? 另外,请注意,我是一个初学者,仅通过在Google上进行网上搜索并亲自发现问题就已经实现了很多功能。

videoplayer.java:

package com.example.newapp;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewSwitcher;

import com.blogspot.atifsoftwares.animatoolib.Animatoo;
import com.sprylab.android.widget.TextureVideoView;

import org.w3c.dom.Text;

import bg.devlabs.fullscreenvideoview.FullscreenVideoView;

public class videoplayer extends Activity implements View.OnTouchListener{

   private TextureVideoView mVV;

    MediaController control;
    int i=0;


    @Override
    public void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.videoplayer);

        Intent intent=getIntent();
        String previousa=intent.getStringExtra("activity");



        mVV = (TextureVideoView) findViewById(R.id.myvideoview);

        String videopath;


        videopath = "android.resource://" + getPackageName() + "/" + R.raw.overviewed;

        Uri ur = Uri.parse(videopath);
        mVV.setVideoURI(ur);
        mVV.setMediaController(control);
        mVV.setOnTouchListener(this);
        control = new MediaController(this);
        control.setAnchorView(mVV);

        mVV.start();
    }
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        i++;

        int lastloc=1;

        if(i%2==1)
        {
            lastloc=mVV.getCurrentPosition();
           mVV.pause();

        }
        else {

 //           mVV.seekTo(lastloc);
            mVV.start();
        }


        return true;
    }

}

videoplayer.xml:

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

            <com.sprylab.android.widget.TextureVideoView
                android:id="@+id/myvideoview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

非常感谢您抽出宝贵的时间来帮助我。

0 个答案:

没有答案