在VideoView在Android中播放视频 [英] Playing a video in VideoView in Android

查看:175
本文介绍了在VideoView在Android中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不通为什么我不能在我的VideoView播放视频。所有我得到的消息是无法播放视频:很抱歉,此视频无法播放。

I can't figure out why am i not able to play the video in my VideoView. All i'm getting a message is Cannot Play Video : Sorry, this video cannot be played.

我创建了一个SD卡为我的模拟器为好。我需要把我的SD卡在我的SDK中的特定文件夹?请发表评论。

I created an SD card for my emulator as well. Do i need to place me SD card in a particular folder in my SDK? Please comment.

下面的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
   android:id="@+id/LinearLayout01"
   android:layout_height="fill_parent"     
   android:paddingLeft="2px"
   android:paddingRight="2px"
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:paddingTop="2px"
   android:paddingBottom="2px"
   android:layout_width="fill_parent"
   android:orientation="vertical">

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

</LinearLayout>

下面是code:

package com.examples.videoviewdemo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoViewDemo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        VideoView videoView = (VideoView)findViewById(R.id.VideoView);
        //MediaController mediaController = new MediaController(this);
        // mediaController.setAnchorView(videoView);
        //videoView.setMediaController(mediaController);

        videoView.setVideoPath("/sdcard/blonde_secretary.3gp");

        videoView.start();  
    }
}

等待答复...

Waiting for the reply...

推荐答案

我的猜测是,你的影片是与Android兼容。尝试用不同的视频。 这其中绝对<打击>和。如果该影视作品,和你没有,那么你的视频不与Android兼容。

My guess is that your video is incompatible with Android. Try it with a different video. This one definitely works used to work with Android (but does not on newer devices, for some reason). If that video works, and yours does not, then your video is not compatible with Android.

正如其他人所指出的,请在设备上进行测试。在模拟器上视频播放需要太多电能。

As others have indicated, please test this on a device. Video playback on the emulator requires too much power.

这篇关于在VideoView在Android中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆