2012-07-19 212 views
6

好吧,這有點令人沮喪,我已經搜索了Stack,但沒有一個答案似乎有所幫助。Android視頻在多次播放後停止播放錯誤1,2147483648

我有一個Android應用程序,它循環顯示屏幕上的不同內容。有一次,它播放一個視頻,同一個視頻,從同一個地方加載。

經過隨機播放次數後,它決定停止播放視頻文件,並將錯誤提示上方(-2147483648),這是一般文件未找到/格式不正確的錯誤。

問題是視頻播放正確無數次,然後出現此錯誤。我已經嘗試了一些替代品來解決這個:

  • 一個VideoView播放文件(開始)
  • 媒體播放+ SurfaceView組合從文件中讀取
  • 的MediaPlayer + SurfaceView從文件描述符讀取
  • 強制將權限設置爲全球可讀
  • 將文件複製到臨時文件並播放此
  • 手動爲VideoView和MediaPlayer選項手動釋放媒體播放器
  • 運行手動垃圾收集各自發揮

,但仍後,多次播放完畢後,最終,它會拒絕播放視頻。

可能或可能不相關的一個變化是,當從文件描述符播放時,它會拋出一個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 mediaplaying例子幾乎一模一樣,但我不認爲這是值得粘貼代碼,因爲錯誤發生,無論您使用mediaplayer + surfaceview方法或VideoView播放方法。

想法?快把我逼瘋。

UPDATE:下面是完整的日誌包括主應用程序和催生了視頻活動

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小時。所以,它看起來是一個平臺錯誤,但仍然需要解決這個問題。

+0

可以粘貼錯誤日誌,請包含錯誤以上的行 – 2012-07-19 07:16:34

+0

我只是再次運行它,將很快粘貼日誌,請注意我現在正在運行SurfaceView。可能需要半個小時才能崩潰。 – DoctorDbx 2012-07-19 07:44:45

+0

確定已更新。請注意,我必須從重新啓動中獲取此日誌,但錯誤是一樣的。看着它說'沒有編解碼器失敗',但當然,它已經在此之前正確播放了37次視頻。 – DoctorDbx 2012-07-19 08:56:25

回答

1

我幾乎肯定這是你使用的基於Amlogic的設備的一個問題(顯然是因爲logcat中的「amplayer」和「AmlogicPlayer」)。我們正在測試的基於Amlogic AML8726的設備存在大量問題。如果可能,請嘗試升級固件。

+1

的確,這是正在使用的盒子上的芯片組。已將固件升級到製造商提供的最新版本。但這並沒有解決問題。它也有其他一些問題。 – DoctorDbx 2012-08-25 01:41:53

+0

基於Amlogic的設備仍然存在AmlogicPlayer的問題,與其他設備相比,直播流緩衝仍然非常慢。所有經過測試的Amlogic設備(總共4個),rk3188上3秒和三星gt9200上3秒的相同流的加載時間爲8秒。真的很刺激! – ole 2015-08-24 08:38:30

0

我不確定但我認爲這是由於一些緩存問題,因爲它播放x次然後停止播放。文件不可訪問,可能是由於多種原因:權限,損壞的文件,錯誤的文件,但你似乎是一個不同的情況。

你可以使用reset,然後再試一次

公共無效復位()自:API等級1

重置在MediaPlayer其未初始化的狀態。調用這個 方法後,您必須通過設置數據源 並調用prepare()來重新初始化它。

+0

我會這樣做,但也許可能需要進一步解釋一下,視頻的實際播放是在不同的活動中進行的,以保留之前的佈局和活動。播放完成後,finish()會在該活動上被調用,並且它應該被銷燬。因此調用重置並不重要嗎?但..會放棄它。 – DoctorDbx 2012-07-19 09:19:05

+0

reset()不起作用。同樣的錯誤。 : -/ – DoctorDbx 2012-07-19 09:46:23

+0

好的,你可以在一個活動中創建/複製你的文件並在另一個活動中播放,只是出於好奇你在播放該文件之前檢查。在構建/複製該文件結束時可能會發生一些問題。 – 2012-07-19 10:00:39

0

好吧,我從來沒有解決這個問題到我的最終滿意度,特別是因爲它是特定的設備。最後,我只是在異常處理中添加了這樣的功能,以便在播放視頻失敗時不會崩潰,下次再跳過並重試。

視頻確實在下一次循環播放,所以我猜測它是特定於設備的東西。