我的应用程序出现黑屏/冻结错误,我无法解决。所以我做了一个小应用程序,循环播放两个视频,试图重现错误。我成功了。
Android日志中的错误是:
08-26 06:04:12.426 D/CDX_Player( 90): >>>>>>>> CedarX Player Version: 00010707
08-26 06:04:12.426 I/CedarPlayerWrapper( 90): setDataSource('/mnt/sdcard/cman/video1.mp4')
08-26 06:04:12.426 I/WindowManager( 156): MediaPlayer.isPlayingVideo
08-26 06:04:12.526 D/osal_linux( 90): init hw ref count:1
08-26 06:04:12.536 D/MediaPlayer(14489): getMetadata
08-26 06:04:12.546 D/VideoDec_Component( 90): vdec touch cpu freq
08-26 06:04:12.566 D/AudioDec_Component( 90): touch cpu freq
08-26 06:04:12.606 D/SurfaceTextureClient( 90): dispatchSetBuffersGeometry1!
08-26 06:04:12.606 D/SurfaceTextureClient( 90): dispatchSetBuffersGeometry2!
08-26 06:04:12.606 D/ ( 90): layer_info.w = 1280
08-26 06:04:12.606 D/ ( 90): layer_info.h = 720
08-26 06:04:12.606 D/ ( 90): layer_info.format = 86
08-26 06:04:12.606 D/ ( 90): layer_info.screenid = 0
08-26 06:04:12.606 D/ ( 87): layer_info.w = 1280
08-26 06:04:12.606 D/ ( 87): layer_info.h = 720
08-26 06:04:12.606 D/ ( 87): layer_info.format = 86
08-26 06:04:12.606 D/ ( 87): layer_info.screenid = 0
08-26 06:04:12.616 I/hwcomposer( 87): layer open hdl:101,ret :0
08-26 06:04:15.636 D/AudioDec_Component( 90): touch cpu freq
08-26 06:04:15.996 D/AudioDec_Component( 90): touch cpu freq
08-26 06:04:17.026 D/AudioDec_Component( 90): touch cpu freq
08-26 06:04:17.536 W/mov_parser( 90): retrun read finish
08-26 06:04:17.536 E/mov_parser_oal( 90): Try to read sample failed!
08-26 06:04:17.536 W/mov_parser( 90): retrun read finish
08-26 06:04:17.536 E/mov_parser_oal( 90): Try to read sample failed!
08-26 06:04:19.476 D/VideoDec_Component( 90): vdec touch cpu freq
08-26 06:04:19.486 D/CedarXPlayer( 90): MEDIA_PLAYBACK_COMPLETE
08-26 06:04:19.496 W/MediaPlayer(14489): info/warning (702, 0)
08-26 06:04:19.496 I/MediaPlayer(14489): Info (702,0)
08-26 06:04:19.596 D/osal_linux( 90): exit hw ref count:0
08-26 06:04:19.596 D/CDX_Player( 90): >>>>>>>> CedarX Player Version: 00010707
08-26 06:04:19.596 I/CedarPlayerWrapper( 90): setDataSource('/mnt/sdcard/cman/video2.wmv')
08-26 06:04:19.606 I/WindowManager( 156): MediaPlayer.isPlayingVideo
08-26 06:04:19.656 D/osal_linux( 90): init hw ref count:1
08-26 06:04:19.676 D/MediaPlayer(14489): getMetadata
08-26 06:04:19.676 D/VideoDec_Component( 90): vdec touch cpu freq
08-26 06:04:19.686 E/JavaBinder(14489): !!! FAILED BINDER TRANSACTION !!!
08-26 06:04:19.696 D/SurfaceTextureClient( 90): dispatchSetBuffersGeometry1!
08-26 06:04:19.696 D/SurfaceTextureClient( 90): dispatchSetBuffersGeometry2!
08-26 06:04:19.696 D/ ( 90): layer_info.w = 1280
08-26 06:04:19.696 D/ ( 90): layer_info.h = 720
08-26 06:04:19.696 D/ ( 90): layer_info.format = 86
08-26 06:04:19.696 D/ ( 90): layer_info.screenid = 0
08-26 06:04:19.696 D/ ( 87): layer_info.w = 1280
08-26 06:04:19.696 D/ ( 87): layer_info.h = 720
08-26 06:04:19.696 D/ ( 87): layer_info.format = 86
08-26 06:04:19.696 D/ ( 87): layer_info.screenid = 0
08-26 06:04:19.736 I/hwcomposer( 87): layer open hdl:101,ret :0
08-26 06:04:19.766 D/AudioDec_Component( 90): touch cpu freq
08-26 06:04:20.806 W/ThrottleService( 156): unable to find stats for iface rmnet0
08-26 06:04:24.236 D/AudioDec_Component( 90): touch cpu freq
08-26 06:04:24.586 W/asf_parser( 90): data object error!
08-26 06:04:24.586 W/asf_parser_oal( 90): Try to read sample failed!
08-26 06:04:24.586 W/AudioDec_Component( 90): audiodec ret: -2
08-26 06:04:26.666 D/VideoDec_Component( 90): vdec touch cpu freq
08-26 06:04:26.676 D/CedarXPlayer( 90): MEDIA_PLAYBACK_COMPLETE
08-26 06:04:26.696 W/MediaPlayer(14489): info/warning (702, 0)
08-26 06:04:26.696 I/MediaPlayer(14489): Info (702,0)
08-26 06:04:57.846 D/dalvikvm( 224): GC_CONCURRENT freed 386K, 75% free 7848K/30279K, paused 2ms+5ms
08-26 06:08:18.156 D/dalvikvm( 224): GC_CONCURRENT freed 382K, 75% free 7851K/30279K, paused 2ms+4ms
08-26 06:08:40.536 D/dalvikvm( 156): GC_CONCURRENT freed 510K, 9% free 8946K/9735K, paused 2ms+5ms
08-26 06:10:41.816 I/EventLogService( 383): Aggregate from 1377510041773 (log), 1377510041773 (data)
08-26 06:11:44.456 D/dalvikvm( 224): GC_CONCURRENT freed 387K, 75% free 7850K/30279K, paused 2ms+6ms
08-26 06:14:20.806 W/ThrottleService( 156): unable to find stats for iface rmnet0
08-26 06:15:23.786 D/dalvikvm( 224): GC_CONCURRENT freed 383K, 75% free 7851K/30279K, paused 2ms+5ms
08-26 06:17:50.136 D/dalvikvm( 156): GC_CONCURRENT freed 500K, 9% free 8938K/9735K, paused 2ms+5ms
08-26 06:18:46.096 D/dalvikvm( 224): GC_CONCURRENT freed 387K, 75% free 7850K/30279K, paused 2ms+4ms
Application Output的错误是:
[MediaPlayer] getMetadata
[MediaPlayer] info/warning (702, 0)
[MediaPlayer] Info (702,0)
[MediaPlayer] getMetadata
[JavaBinder] !!! FAILED BINDER TRANSACTION !!!
[MediaPlayer] info/warning (702, 0)
[MediaPlayer] Info (702,0)
我在互联网上看到的可能是我设置视频的方式,我应该使用SetURI,这有意义吗?
我使用的代码是:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.IO;
namespace SimpleVideoPlayer
{
[Activity (Label = "SimpleVideoPlayer", MainLauncher = true)]
public class MainActivity : Activity, Android.Media.MediaPlayer.IOnCompletionListener, Android.Media.MediaPlayer.IOnErrorListener
{
int flag = 1;
string path1 = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "cman/video1.mp4");
string path2 = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "cman/video2.wmv");
VideoView videoView;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
RequestWindowFeature (WindowFeatures.NoTitle);
Window.SetFlags (WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
videoView = FindViewById<VideoView> (Resource.Id.videoView1);
// Seta esta classe como a classe a ser chamada quando o video acabar de ser executado
videoView.SetOnCompletionListener (this);
videoView.SetOnErrorListener (this);
videoView.SetVideoPath (path1);
videoView.Start ();
}
public void OnCompletion (Android.Media.MediaPlayer mp)
{
if (flag == 1) {
videoView.SetVideoPath (path2);
flag = 2;
videoView.Start ();
} else if (flag == 2) {
videoView.SetVideoPath (path1);
flag = 1;
videoView.Start ();
}
}
public bool OnError (Android.Media.MediaPlayer mp, Android.Media.MediaError what, int extra)
{
return true;
}
}
}
布局非常简单:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<VideoView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/videoView1" />
</LinearLayout>
非常感谢你。
此致
Igor Guerra答案 0 :(得分:0)
为您的视频对象添加此侦听器
videoView.setOnInfoListener(infoListener);
infoListener将是这样的:
private OnInfoListener infoListener = new OnInfoListener() {
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if(what==702 && extra == 0 && !mp.isPlaying()){
videoView.stopPlayback();
videoView = null;
// Now reinitialise the videoView and setVideoPath(String) and then start() again
}
return true;
}
};