Android视频在多次播放错误1,2147483648后停止播放

时间:2012-07-19 07:03:35

标签: android android-videoview android-mediaplayer

好的,这有点令人沮丧,我已经搜索了Stack,但没有一个答案似乎有帮助。

我有一个Android应用程序,可以在屏幕上循环显示不同的内容。有一次,它播放视频,同一视频,从同一个地方加载。

在随机播放次数后,它决定停止播放视频文件并将错误抛出(-2147483648),这是一个未找到的通用文件/格式错误。

问题是在出现此错误之前,视频会多次正确播放。我已经尝试了许多替代方法来解决这个问题:

  • 播放文件的VideoView(开头)
  • 从文件
  • 读取MediaPlayer + SurfaceView组合
  • 从文件描述符
  • 读取MediaPlayer + SurfaceView
  • 强制使用世界可读的权限
  • 将文件复制到临时文件并播放
  • 手动释放VideoView和MediaPlayer选项的媒体播放器
  • 每次播放后运行手动垃圾收集

然而,经过多次播放后,它最终会拒绝播放视频。

一个可能或可能没有相关的变化是,当从文件描述符播放时,它会抛出一个媒体播放器准备Java I / O异常,我认为这可能与某些锁定发生在文件上有关。

解决此问题的唯一方法是重启设备。重新启动应用程序无法修复它,它会立即拒绝播放该文件。

以下是VideoView播放代码:

// from main activity
File afile = new File(btvapp.fileroot,btvapp.getDailyVideo().get("FILENAME"));        
afile.setReadable(true, false);
theVideo = (VideoView) findViewById(R.id.videoViewer);
theVideo.requestFocus();
theVideo.setVideoPath(afile.getPath());
theVideo.setOnPreparedListener(this);
theVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
    @Override
    public void onCompletion(MediaPlayer mp) {
        // TODO Auto-generated method stub
        //mp.release();
        theVideo.stopPlayback();
        mp.release();
            finish();

    }
} );
theVideo.setOnErrorListener(new MediaPlayer.OnErrorListener() {
    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
            finish();
            return false;
        }
    });

// play on prepared function
@Override
  public void onPrepared(MediaPlayer mp) {
  // TODO Auto-generated method stub
  mp.start();
}

表面视图几乎完全使用Android SDK媒体播放示例,但我认为不值得粘贴代码,因为无论您使用的是mediaplayer + surfaceview方法还是VideoView播放方法,都会发生错误。

思考?让我发疯了。

更新:这是包含主应用和衍生视频活动的完整日志

07-19 18:47:02.844: V/videpath(7232): /mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4
07-19 18:47:03.014: I/dalvikvm(7232): threadid=1: recursive native library load attempt (/system/lib/libmedia_jni.so)
07-19 18:47:03.014: D/MtpDeviceJNI(7232): register_android_mtp_MtpDevice
07-19 18:47:03.014: I/dalvikvm(7232): threadid=1: recursive native library load attempt (/system/lib/libmedia_jni.so)
07-19 18:47:03.014: I/dalvikvm(7232): threadid=1: recursive native library load attempt (/system/lib/libmedia_jni.so)
07-19 18:47:03.024: V/MediaPlayerService(87): Client(56) constructor
07-19 18:47:03.024: V/MediaPlayerService(87): Create new client(56) from pid 7232, uid 10043, 
07-19 18:47:03.034: V/MediaPlayerService(87): setDataSource(/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4)
07-19 18:47:03.034: V/MediaPlayerService(87): media.amsuperplayer.enable is enabled
07-19 18:47:03.034: V/MediaPlayerService(87): media.amsuperplayer.enable is enabled
07-19 18:47:03.034: V/MediaPlayerService(87): player type = 6
07-19 18:47:03.034: V/MediaPlayerService(87): Create AmSuperPlayer
07-19 18:47:03.034: V/AmSuperPlayer(87): [AmSuperPlayer::74]
07-19 18:47:03.034: V/AmSuperPlayer(87): [AmSuperPlayer::76]
07-19 18:47:03.034: V/AmSuperPlayer(87): AmSuperPlayer init now
07-19 18:47:03.034: V/AmSuperPlayer(87): [onFirstRef::103]
07-19 18:47:03.034: V/AmSuperPlayer(87): [initCheck::110]
07-19 18:47:03.034: V/AmSuperPlayer(87): [initCheck::112]
07-19 18:47:03.034: V/AmSuperPlayer(87): [setNotifyCallback::455]
07-19 18:47:03.034: V/AmSuperPlayer(87): [hardwareOutput::330]
07-19 18:47:03.034: V/AmSuperPlayer(87): [hardwareOutput::332]
07-19 18:47:03.034: V/AudioSink(87): AudioOutput(112)
07-19 18:47:03.034: V/MediaPlayerService(87):  setDataSource
07-19 18:47:03.034: V/AmSuperPlayer(87): [setDataSource::118]
07-19 18:47:03.034: V/AmSuperPlayer(87): [setDataSource::120]
07-19 18:47:03.034: V/MediaPlayerService(87): [56] setVideoSurfaceTexture(0x28290)
07-19 18:47:03.034: V/AmSuperPlayer(87): [setVideoSurfaceTexture::168]
07-19 18:47:03.034: V/AmSuperPlayer(87): [setVideoSurfaceTexture::170]
07-19 18:47:03.034: V/MediaPlayerService(87): [56] setVideoSurfaceTexture(0x29660)
07-19 18:47:03.034: V/MediaPlayerService(87): [56] setAudioStreamType(3)
07-19 18:47:03.034: V/MediaPlayerService(87): [56] prepareAsync
07-19 18:47:03.034: V/AmSuperPlayer(87): [prepareAsync::199]
07-19 18:47:03.034: V/AmSuperPlayer(87): [prepareAsync::202]
07-19 18:47:03.034: V/AmSuperPlayer(87): initThread(7388) started
07-19 18:47:03.034: V/AmSuperPlayer(87): createPlayer
07-19 18:47:03.034: V/AmSuperPlayer(87): Create Amlogic Player
07-19 18:47:03.034: V/AmlogicPlayer(87): AmlogicPlayer constructor
07-19 18:47:03.034: I/AmlogicPlayer(87): media.amplayer.stopbuflevel is not set
07-19 18:47:03.034: V/AmlogicPlayer(87): onFirstRef
07-19 18:47:03.034: I/AmlogicPlayer(87): found 0 not exit player threads,try exit it now
07-19 18:47:03.034: V/AmlogicPlayer(87): initCheck
07-19 18:47:03.034: V/AmSuperPlayer(87): [CreatePlayer::678]
07-19 18:47:03.034: V/AmlogicPlayer(87): setDataSource
07-19 18:47:03.034: V/AmlogicPlayer(87): History mgt old[,0,-1]
07-19 18:47:03.034: V/AmlogicPlayer(87): History mgt    [/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4,0,0]
07-19 18:47:03.034: V/AmlogicPlayer(87): setDataSource url=/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4, len=63
07-19 18:47:03.034: V/AmlogicPlayer(87): Set setVideoSurfaceTexture
07-19 18:47:03.034: I/AmlogicPlayer(87): media.amplayer.lpbufferlevel is not set
07-19 18:47:03.034: I/AmlogicPlayer(87): media.amplayer.buffertime is not set
07-19 18:47:03.034: V/AmlogicPlayer(87): prepareAsync
07-19 18:47:03.034: I/AmlogicPlayer(87): media.amplayer.noaudio is disabled
07-19 18:47:03.034: I/AmlogicPlayer(87): media.amplayer.novideo is disabled
07-19 18:47:03.034: V/AmlogicPlayer(87): buffer level setting is:0.001000-0.020000-0.800000
07-19 18:47:03.034: V/AmlogicPlayer(87): prepareAsync,file_name=/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4
07-19 18:47:03.034: I/amplayer(87): LibPlayer version:Version:2.1.0.
07-19 18:47:03.034: I/amplayer(87): LibPlayer git version:
07-19 18:47:03.034: I/amplayer(87): LibPlayer version serial:201000000000000
07-19 18:47:03.034: I/amplayer(87): LibPlayer Last Changed:
07-19 18:47:03.034: I/amplayer(87): LibPlayer Last Build: Tue May 22 17:40:26 HKT 2012
07-19 18:47:03.034: I/amplayer(87): LibPlayer Builer Name: clei
07-19 18:47:03.034: I/amplayer(87): [player_start:enter]p=0x2a98dc black=0
07-19 18:47:03.034: I/amplayer(87): ***player_para=0x112d28,start_param=0x2a98dc
07-19 18:47:03.034: I/amplayer(87): [player_thread_create:70]creat thread success,tid=149280
07-19 18:47:03.034: I/amplayer(87): [player_start:exit]pid = 23 
07-19 18:47:03.034: V/AmlogicPlayer(87): Start player,pid=23
07-19 18:47:03.034: I/amplayer(87): pid[23]::enter into player_thread
07-19 18:47:03.034: I/amplayer(87): pid[23]::Init State: mute_on=0 black=0 t_pos:1074106323s read_max_cnt=0
07-19 18:47:03.034: I/amplayer(87): file::::[/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4],len=63
07-19 18:47:03.154: I/amplayer(87): **[update_state]pid:23 status=BEGIN_INIT(last:UNKNOW_STATE) err=0x0 curtime=0 (ms:0) fulltime=0 lsttime=0
07-19 18:47:03.154: I/amplayer(87): **[update_state]abuflevel=0.000 vbublevel=0.000 abufrp=0 vbufrp=0 read_end=0
07-19 18:47:03.154: V/AmlogicPlayer(87): update_process pid=23, current=0,status=[BEGIN_INIT]
07-19 18:47:03.154: V/AmlogicPlayer(87): Playing percent =0,mPlayTime:0,mStreamTime:0
07-19 18:47:03.154: V/AmSuperPlayer(87): [notify::404]
07-19 18:47:03.154: V/AmSuperPlayer(87): [Notify::411]
07-19 18:47:03.154: V/AmSuperPlayer(87): cookie=0x475e0,msg=3,ext1=0,ext2=0
07-19 18:47:03.154: I/amplayer(87): [ffmpeg_open_file] file=/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4,header=
07-19 18:47:03.154: I/amplayer(87): ffmpeg error: Couldn't open input file! ret==ffffffe8
07-19 18:47:03.154: I/amplayer(87): [player_dec_init]ffmpeg_open_file failed(/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4)*****ret=fcffffff!
07-19 18:47:03.154: I/amplayer(87): pid[23]player_thread release0 begin...(sta:0x30001)
07-19 18:47:03.154: I/amplayer(87): [get_pts_video]No codec handler
07-19 18:47:03.154: I/amplayer(87): **[update_state]pid:23 status=ERROR(last:BEGIN_INIT) err=0x3000001 curtime=0 (ms:0) fulltime=0 lsttime=0
07-19 18:47:03.154: I/amplayer(87): **[update_state]abuflevel=0.000 vbublevel=0.000 abufrp=0 vbufrp=0 read_end=0
07-19 18:47:03.154: V/AmlogicPlayer(87): update_process pid=23, current=0,status=[ERROR]
07-19 18:47:03.154: V/AmSuperPlayer(87): [notify::404]
07-19 18:47:03.154: V/AmSuperPlayer(87): [Notify::411]
07-19 18:47:03.154: V/AmSuperPlayer(87): cookie=0x475e0,msg=64,ext1=1,ext2=fcffffff
07-19 18:47:03.154: V/AmSuperPlayer(87): [CreatePlayer::702]
07-19 18:47:03.154: I/AmSuperPlayer(87): media.amplayer.enable is enabled
07-19 18:47:03.154: I/AmSuperPlayer(87): media.stagefright.enable-player is disabled
07-19 18:47:03.154: V/AmSuperPlayer(87): [CreatePlayer::713]
07-19 18:47:03.154: V/AmSuperPlayer(87): Need to creat new player=3
07-19 18:47:03.154: V/AmlogicPlayer(87): stop
07-19 18:47:03.154: I/amplayer(87): [player_stop:enter]pid=23
07-19 18:47:03.154: I/amplayer(87): [player_stop]player_status=30001
07-19 18:47:03.154: I/amplayer(87): [player_stop]pid=23 thread is already stopped
07-19 18:47:03.154: V/AmlogicPlayer(87): AmlogicPlayer destructor
07-19 18:47:03.154: V/AmlogicPlayer(87): release
07-19 18:47:03.154: V/AmlogicPlayer(87): [release::1461]
07-19 18:47:03.154: I/amplayer(87): [player_stop:enter]pid=23
07-19 18:47:03.154: I/amplayer(87): [player_stop]player_status=30001
07-19 18:47:03.154: I/amplayer(87): [player_stop]pid=23 thread is already stopped
07-19 18:47:03.154: I/amplayer(87): [player_exit:enter]pid=23
07-19 18:47:03.154: I/amplayer(87): [player_exit]player_state=0x30001
07-19 18:47:03.154: I/amplayer(87): [player_stop:enter]pid=23
07-19 18:47:03.154: I/amplayer(87): [player_stop]player_status=30001
07-19 18:47:03.154: I/amplayer(87): [player_stop]pid=23 thread is already stopped
07-19 18:47:03.154: I/amplayer(87): [player_thread_wait_exit:80]pid=[23] thead_id=149280
07-19 18:47:03.154: V/AmlogicPlayer(87): Player status:ERROR, error occur
07-19 18:47:03.154: V/AmSuperPlayer(87): [notify::404]
07-19 18:47:03.154: V/AmSuperPlayer(87): [Notify::411]
07-19 18:47:03.154: V/AmSuperPlayer(87): cookie=0x475e0,msg=64,ext1=1,ext2=ffffffff
07-19 18:47:03.154: I/amplayer(87): **[update_state]pid:23 status=EXIT(last:ERROR) err=0x0 curtime=0 (ms:0) fulltime=0 lsttime=0
07-19 18:47:03.154: I/amplayer(87): **[update_state]abuflevel=0.000 vbublevel=0.000 abufrp=0 vbufrp=0 read_end=0
07-19 18:47:03.154: V/AmlogicPlayer(87): update_process pid=23, current=0,status=[EXIT]
07-19 18:47:03.154: V/AmlogicPlayer(87): Player status:EXIT, playback exit
07-19 18:47:03.154: I/amplayer(87): pid[23]::stop play, exit player thead!(sta:0x30004)
07-19 18:47:03.154: I/amplayer(87): [player_thread_wait_exit:86]thead_id=149280 returning
07-19 18:47:03.154: I/amplayer(87): [player_exit]player thread already exit: 0
07-19 18:47:03.154: I/amplayer(87): [player_release_pid:72]release pid=23
07-19 18:47:03.154: I/amplayer(87): [player_exit:exit]pid=23
07-19 18:47:03.154: V/AmlogicPlayer(87): set fs/sys/class/video/disable_video=2 failed
07-19 18:47:03.154: I/amplayer(87): ENABLE_FREE_SCALE not define!
07-19 18:47:03.154: I/amplayer(87): [get_display_mode]display_mode=fail
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb0/scale fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb1/scale fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb1/scale_axis fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb0/blank fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb1/blank fail.
07-19 18:47:03.154: I/amplayer(87): [get_display_mode]display_mode=fail
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb0/free_scale fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/graphics/fb1/free_scale fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/video/axis fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/ppmgr/ppscaler fail.
07-19 18:47:03.154: I/amplayer(87): open /sys/class/ppmgr/ppscaler_rect fail.
07-19 18:47:03.154: I/amplayer(87): display mode: 292344
07-19 18:47:03.154: I/amplayer(87): [enable_freescale_MBX]set video axis: 0 0 0 0 
07-19 18:47:03.154: V/AmlogicPlayer(87): VideoViewClose=-33554433
07-19 18:47:03.154: V/AmlogicPlayer(87): [release::1471]
07-19 18:47:03.154: V/AmlogicPlayer(87): History mgt old[,0,-1]
07-19 18:47:03.154: V/AmlogicPlayer(87): History mgt    [/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4,1,0]
07-19 18:47:03.154: V/AmSuperPlayer(87): createPlayer
07-19 18:47:03.154: V/AmSuperPlayer(87):  create StagefrightPlayer
07-19 18:47:03.154: V/AmSuperPlayer(87): [CreatePlayer::678]
07-19 18:47:03.154: I/AwesomePlayer(87): setDataSource_l('/mnt/sdcard/Android/data/au.com.nian.bullertv/files/tmpbtag.mp4')
07-19 18:47:03.154: V/AmSuperPlayer(87): [CreatePlayer::713]
07-19 18:47:03.154: V/AmSuperPlayer(87): [CreatePlayer::729]
07-19 18:47:03.154: V/AmSuperPlayer(87): Start new player now=3
07-19 18:47:03.154: V/AmSuperPlayer(87): [initThread::762]
07-19 18:47:03.154: V/AmSuperPlayer(87): [notify::404]
07-19 18:47:03.154: V/AmSuperPlayer(87): [Notify::411]
07-19 18:47:03.154: V/AmSuperPlayer(87): cookie=0x475e0,msg=64,ext1=1,ext2=80000000
07-19 18:47:03.154: V/MediaPlayerService(87): [56] notify (0x23d50, 100, 1, -2147483648)
07-19 18:47:03.154: **E/MediaPlayer(7232): error (1, -2147483648)**
07-19 18:47:03.154: V/videoerr(7232): java.io.IOException: Prepare failed.: status=0x1

更新2: 我已经在其他2个Android设备(一个ICS,一个姜饼)上测试了代码,并且烦人地在它们上运行正常并且运行了12个多小时没有发生任何事故。所以,它看起来是一个平台错误,但仍然需要解决这个问题。

3 个答案:

答案 0 :(得分:1)

我几乎肯定这是你正在使用的基于Amlogic的设备的问题(显然是由于logcat中的“amplayer”和“AmlogicPlayer”)。我们正在测试的基于Amlogic AML8726的设备存在很多问题。如果可能,请尝试升级固件。

答案 1 :(得分:0)

我不确定但我认为这是由于某些缓存问题,因为它播放x次然后停止播放。文件无法访问可能是由于多种原因:权限,文件损坏,文件错误,但您的情况似乎不同。

您可以使用reset并重试

  

public void reset()从:API Level 1

     

将MediaPlayer重置为未初始化状态。打电话给这个   方法,您必须通过设置数据再次初始化它   来源和调用prepare()。

答案 2 :(得分:0)

好吧,我从来没有把这个解决到最终的满足感,特别是因为它特别适用于某个设备。最后我刚刚添加了异常处理,因此在播放视频时不会崩溃,只是跳过它并在下次再试一次。

视频确实在下一次循环播放,所以我猜这是设备特有的。