Android的媒体播放器无法正常工作 [英] android media player not working

查看:159
本文介绍了Android的媒体播放器无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个应用程序,有很多的视频嵌入到它,我想叫Android的媒体播放器,与VideoView对象的视频。但是,我得到这些奇怪的错误:

I'm trying to develop an app that has many videos embedded in it, and I'd like to call Android's Media Player, with the video on VideoView object. However, i get these strange errors:

  • 在I / MediaPlayer的(2874):信息(1,26)
  • E / MediaPlayer的(2874):错误(-4,-4)
  • D / VideoView(2874):错误:-4,-4

当我尝试播放MP4视频,或者未从我的手机录制了3GP视频。我的code是这样的:

when i try to play a mp4 video, or another 3gp video that is not recorded from my phone. My code is something like:

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

public class PlayTest2 extends Activity{
private MediaController ctlr;
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test2);

    try {
        VideoView video = (VideoView) findViewById(R.id.test2);
        // Load and start the movie
                video.setVideoPath("android.resource://com.example.child.protector/raw/output");
        ctlr=new MediaController(this);
        ctlr.setMediaPlayer(video);
        video.setMediaController(ctlr);
        video.start();
        //video.requestFocus();//this line is new
    }
    catch (Exception e) {
       Log.e("---------- this is my app --------", "error: " + e.getMessage(), e);

    }
}
}

和我的布局是这样的:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<VideoView
android:id="@+id/test2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
/>
</FrameLayout>

是不是有什么毛病我code?

Is there something wrong with my code?

和我知道,我的文件是存在的,所有的。我碰到这个code与样品3GP视频和它的工作只是罚款(但我从我的手机录制的视频并将其复制到我的电脑,然后重新包装在我的应用程序,在/ RES /生夹在Eclipse)。然而,问题是,由于某些原因,我的媒体播放器只能播放某些3GPP文件。如果我尝试将MP4转换为使用MobileMediaConverter 3GP,小青在我的笔记本电脑,但不能在此应用程序。还要注意的是,如果我打开视频作为一个文件(换句话说,调用我的三星Galaxy S手机默认视频播放器),它工作得很好(意为我的手机拥有的功能)。所以我想知道:

and i know that my file is there and all. I've run this code with a sample 3GP video and it worked just fine (but i recorded the video from my phone and copied it to my computer and then re-packaged in to my app, under the /res/raw folder in Eclipse). However, The problem is that for some reason, my media player only plays certain 3GPP files. If i try to convert a MP4 to 3GP using MobileMediaConverter, it plays on my laptop but not in this app. Also note that if i open the video as a file (in other words, invoking the default video player on my Samsung Galaxy S phone) it works just fine (meaning my phone has the capabilities). So i'm wondering:

  • 这是什么毛病code?
  • 这更多的是MP4转换为3GP错误?

任何帮助将是很大的AP preciated。谢谢!

Any help would be greatly appreciated. Thanks!!

推荐答案

问题是一定的转换器(使用不同的设置),将创建一个没有我的三星Galaxy Android设备上运行的视频文件。在code这里是通用的,但我认为codeC已经是这样做的H.264视频转换的时候。然后我下载了大约5视频转换器和2人会真正发挥3GPP,我的设备可以播放。因此,如果任何人有这个问题,我会建议您尝试一堆视频转换器,具有不同的codeC /音频设置。我最终能找到一个在我的具体情况制定

The problem was the certain converters (with different settings) will create a video file that doesn't run on my Samsung Galaxy android device. the code here is generic, but i think the codec has to be something like H.264 when doing the video conversion. I then downloaded about 5 video converters and 2 of them will actually make a 3GPP that my device can play. so if anyone else has this problem, i would recommend trying a bunch of video converters, with different codec/audio settings. i was eventually able to find one that worked in my particular case

这篇关于Android的媒体播放器无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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