android媒体播放器无法正常工作
|
我正在尝试开发一个其中嵌入了许多视频的应用程序,我想调用Android \的Media Player,并将视频放在VideoView对象上。但是,我得到这些奇怪的错误:
I / MediaPlayer(2874):信息(1,26)
E / MediaPlayer(2874):错误(-4,-4)
D / VideoView(2874):错误:-4,-4
当我尝试播放mp4视频或其他未从手机录制的3gp视频时。我的代码是这样的:
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>
我的代码有问题吗?
而且我知道我的文件在那里。我已经使用3GP视频示例运行了此代码,但效果很好(但我从手机录制了视频,然后将其复制到计算机中,然后重新打包到应用程序中的/ res / raw文件夹下,日食)。但是,问题在于由于某种原因,我的媒体播放器仅播放某些3GPP文件。如果我尝试使用MobileMediaConverter将MP4转换为3GP,它可以在笔记本电脑上播放,但不能在此应用程序中播放。还要注意,如果我将视频作为文件打开(换句话说,在我的Samsung Galaxy S手机上调用默认的视频播放器),它就可以正常工作(这意味着我的手机具有该功能)。所以我想知道:
代码有问题吗?
这更多是将mp4转换为3gp错误吗?
任何帮助将不胜感激。谢谢!!
没有找到相关结果
已邀请:
1 个回复
信藉乒