VideoView"无法播放此视频"

时间:2017-06-10 09:38:11

标签: java android android-videoview

我试图在videoView中播放视频,但我无法播放。
这是我的java代码:

package com.ggblbl.videoView;

import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.VideoView;

public class RandomVideoBlueActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_random_video_blue);

        VideoView videoBlue = (VideoView) findViewById(R.id.videoViewBlue);
        String videoPathBlue = "android.resource://"+getPackageName()+"/"+R.raw.blue_video;
        Uri videoUriBlue = Uri.parse(videoPathBlue);
        videoBlue.setVideoURI(videoUriBlue);
        videoBlue.start();
    }
}

我的视频名称为 video_blue.mp4 https://www.dropbox.com/s/iefnweekgbb9owz/blue_video.mp4?dl=0

这是我的活动XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ggblbl.videoView.RandomVideoBlueActivity">

    <VideoView
        android:id="@+id/videoViewBlue"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

我在LG L70(D320n)上测试了它 然而,在我的摩托罗拉Moto G1上,它确实有效。

1 个答案:

答案 0 :(得分:0)

我已经做了一些测试,看起来视频的分辨率对于我可怜的旧手机来说太高了...... 我想我必须找到一种方法来为每部手机缩小它。