如何在没有拉伸的情况下全屏显示视频

时间:2016-10-10 11:25:53

标签: java android



package com.example.pixatra06.myapplication;

import android.content.Intent;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.media.session.MediaController;
import android.net.Uri;
import android.os.CountDownTimer;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.VideoView;

import java.util.logging.Handler;
import java.util.logging.LogRecord;

import static java.lang.Thread.sleep;

public class MainActivity extends AppCompatActivity{
    VideoView videoView;
   // MediaController mediaController;
    SurfaceView surfaceView;
    SurfaceHolder surfaceHolder;
    boolean pausing = false;;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        videoView = (VideoView) findViewById(R.id.videoview);
       // RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
        //videoView.setLayoutParams(params);
       // getWindow().setFormat(PixelFormat.UNKNOWN);
        String uriPath = "android.resource://com.example.pixatra06.myapplication/" + R.raw.bds;
        Uri uri = Uri.parse(uriPath);
        videoView.setVideoURI(uri);
        videoView.requestFocus();
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                jump();

            }
        });
        videoView.start();

    }

    private void jump() {
        if(isFinishing())
            return;
        startActivity(new Intent(this, Home.class));
        finish();
    }
}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.pixatra06.myapplication.MainActivity">

    <VideoView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/videoview"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true" />

</RelativeLayout>
&#13;
&#13;
&#13;        我想在没有拉伸的情况下全屏显示视频视图。 我想在没有拉伸的情况下全屏显示视频视图。 我想在没有拉伸的情况下全屏显示视频视图。 我希望在没有拉伸的情况下全屏显示视频视图。

0 个答案:

没有答案