简体   繁体   English

VideoView仅在Android 4.0.3中不显示仅视频音频

[英]VideoView not showing video only audio coming in android 4.0.3 only

i have a basic example app to play video from res/raw. 我有一个基本的示例应用程序,可以播放来自res / raw的视频。 My problem is that it is not working(only audio playing) in android 4.0.3, but working in 3.2 , 4.3 , 4.4 (emulators). 我的问题是,它在android 4.0.3中不起作用(仅播放音频),但是在3.2,4.3,4.4(模拟器)中工作。 And on a real device (micromax canvas 4 with android 4.2.1) it says app has stopped responding.? 并在实际设备(带有Android 4.2.1的micromax canvas 4)上表示应用已停止响应。 My question how can i play it on all android and why is it not responding on my moblie?? 我的问题是如何在所有android上播放它,为什么我的手机没有响应? and i have already searched on stackoverflow with no positive result.. PLEASE HELP THANKS 并且我已经搜索了stackoverflow,但没有得到任何肯定的结果。

this is my xml file 这是我的xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<VideoView
    android:id="@+id/vidvew"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

</RelativeLayout>

this is my .java file 这是我的.java文件

package com.example.tryit;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.VideoView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    VideoView vv = (VideoView) findViewById(R.id.vidvew);
    String fileName = "android.resource://" + getPackageName() + "/" +R.raw.cs;
    vv.setVideoURI(Uri.parse(fileName));
    vv.start();


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

Check the encoding of the video properly. 正确检查视频的编码。 Android allows only certain types of file types to be played in the app. Android仅允许在应用程序中播放某些类型的文件类型。 Please see the link below for more information - http://developer.android.com/guide/appendix/media-formats.html 请查看下面的链接以获取更多信息-http://developer.android.com/guide/appendix/media-formats.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM