2017-06-10 136 views
0

我試圖在videoView中播放視頻,但我無法播放該視頻。
這裏是我的Java代碼:VideoView「無法播放此視頻」

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上它確實有效。

回答

0

我已經做了一些測試,看起來視頻的分辨率對於我那可憐的老手機來說太高了...... 我想我必須找到一種縮小手機的方法。

相關問題