Android Video stops playing after multiple plays Error 1, 2147483648

白昼怎懂夜的黑 提交于 2020-12-01 10:26:06

问题


OK, this is a little frustrating, and I have searched Stack but none of the answers seems to help.

I have an Android app which cycles through different content on the screen. At one point it plays a video, the same video, loaded from the same place.

After a random number of plays, it decides to stop playing the video file and throws the error up above (-2147483648) which is a generic file not found / incorrect format error.

The problem is the video plays correctly numerous times before this error comes up. I have tried a number of alternatives to fixing this:

  • a VideoView playing a file (the start)
  • a MediaPlayer + SurfaceView combo reading from file
  • MediaPlayer + SurfaceView reading from file descriptor
  • forcing permissions to world readable
  • copying the file to a temporary file and playing this
  • manually releasing the mediaplayer for both the VideoView and MediaPlayer options
  • running manual garbage collection after each play

and yet still, after multiple plays, eventually, it will refuse to play the video.

One change which might or might no be relevant is when playing from a file descriptor it throws a mediaplayer prepare Java I/O Exception which I believe is related to perhaps there is somehow some locking happening on the file.

The only way to fix this is to reboot the device. Restarting the app does not fix it and it immediately will refuse to play the file.

Here is the VideoView playing code:

// 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();
}

The surface view uses the Android SDK mediaplaying example almost exactly, but I don't think it's worth pasting the code, since the error happens regardless of whether you use the mediaplayer + surfaceview method OR the VideoView playback method.

Thoughts? Driving me crazy.

UPDATE: Here's the full log including the main app and the spawned video activity

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

UPDATE 2: I have tested the code on 2 other Android devices (one ICS, one Gingerbread) and annoyingly it works fine on them and ran for over 12 hours without incident. So, it looks to be a platform error, but still need to solve this.


回答1:


I'm almost positive this is an issue with the Amlogic based device you are using (evident due to the "amplayer" and "AmlogicPlayer" in the logcat). We have had tons of issues with an Amlogic AML8726 based device we are testing. Try upgrading the firmware if possible.




回答2:


I am not sure But I think this is due to some caching problem , as it plays for x times and then stops playing . File is not accessible that can be due to multiple reasons :Permissions, corrupt file , wrong file but your seems to be a different case.

Can you use reset and try again

public void reset () Since: API Level 1

Resets the MediaPlayer to its uninitialized state. After calling this method, you will have to initialize it again by setting the data source and calling prepare().




回答3:


OK well, I never did resolve this to my ultimate satisfaction, especially since it was particular to a device. In the end I just added in exception handling so it would not crash when failing to play the video and just skip it and try again next time.

The video does play in the loop the next time around, so I am guessing it is something specific to the device.



来源:https://stackoverflow.com/questions/11555537/android-video-stops-playing-after-multiple-plays-error-1-2147483648

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!