当我播放视频时,使用prepareAsync(),然后在准备视频时调用start(),从我的start()调用到视频实际开始播放大约需要250ms。是这样的,或者这里有什么好玩的?请注意,视频位于原始目录中。在我的活动的OnCreate我有:
private VideoView vv;
private MediaPlayer mp = new MediaPlayer();
vv = (VideoView)findViewById(R.id.vv);
vv.getHolder().addCallback(this);
mp.reset();
mp.setDisplay( vv.getHolder() );
mp.setDataSource( this, Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.moviename) );
Log.d(TAG,"video is preparing");
mp.prepareAsync();
然后是听众:
@Override
public void onPrepared(MediaPlayer arg0) {
Log.d(TAG, "video is prepared");
mp.start();
}
实际上我的代码比这更复杂。用户单击按钮以播放视频,还可以选择不同的视频。我有一个图像隐藏视频,并从mp.start()的一定数量的ms我拉出这个图像并显示视频。在我的设备上,我必须将其设置为250ms,以便可靠地不显示视频以外的内容(某些内容是黑色或上一个视频播放的最后一帧)。
我想知道的是,你是否可以从我的logcat告诉我这是不对的。我很好奇没有标题为ButtonBookActivity的消息。他们是正常的吗?这些是mp4s。请注意,在这种情况下准备视频只需120毫秒。
04-15 13:30:05.600: D/ButtonBookActivity(1238): video is reset
04-15 13:30:05.620: I/NuCachedSource2(83): ERROR_END_OF_STREAM
04-15 13:30:05.630: D/AwesomePlayer(83): Failed to open file, all profile flags have to set through setprop method.
04-15 13:30:05.630: I/MPEG4Extractor(83): NON-QT MODE DECIDED
04-15 13:30:05.640: I/SampleTable(83): There are reordered frames present.
04-15 13:30:05.640: D/ButtonBookActivity(1238): video is preparing
04-15 13:30:05.640: I/OMXCodec(83): [OMX.Nvidia.h264.decode] AVC profile = 77 (Main), level = 32
04-15 13:30:05.640: I/OMXCodec(83): [OMX.Nvidia.h264.decode] video dimensions are 800 x 1280
04-15 13:30:05.640: I/OMXCodec(83): [OMX.Nvidia.h264.decode] Crop rect is 800 x 1280 @ (0, 0)
04-15 13:30:05.760: D/ButtonBookActivity(1238): video is prepared
04-15 13:30:06.540: D/ButtonBookActivity(1238): touch event
04-15 13:30:06.540: D/ButtonBookActivity(1238): button clicked
04-15 13:30:06.550: D/ButtonBookActivity(1238): calling playmovie in onTouch callback
04-15 13:30:06.550: D/ButtonBookActivity(1238): playing movie
04-15 13:30:06.550: D/ButtonBookActivity(1238): delaying movie reveal
04-15 13:30:06.560: D/NvOsDebugPrintf(83): Allocating new output: 800x1280 (x 12)
04-15 13:30:06.570: I/OMXCodec(83): [OMX.Nvidia.h264.decode] video dimensions are 800 x 1280
04-15 13:30:06.570: I/OMXCodec(83): [OMX.Nvidia.h264.decode] Crop rect is 800 x 1280 @ (0, 0)
04-15 13:30:06.620: D/ButtonBookActivity(1238): touch event
04-15 13:30:06.620: D/ButtonBookActivity(1238): ignoring touch event
04-15 13:30:06.770: V/NvAudioALSA(83): open called for devices 00000002 in mode 0...
04-15 13:30:06.770: V/NvAudioALSA(83): getAlsaDeviceName::devices 0x2 IsVoiceCallDevice 0 devName music
04-15 13:30:06.770: V/NvAudioALSA(83): Reset buffer size to 4096 and latency to 92879
04-15 13:30:06.770: V/NvAudioALSA(83): Set PLAYBACK PCM format to S16_LE (Signed 16 bit Little Endian)
04-15 13:30:06.770: V/NvAudioALSA(83): Using 2 channels for PLAYBACK.
04-15 13:30:06.770: V/NvAudioALSA(83): Set PLAYBACK sample rate to 44100 HZ
04-15 13:30:06.770: V/NvAudioALSA(83): Buffer size: 4096
04-15 13:30:06.770: V/NvAudioALSA(83): Period size: 1024
04-15 13:30:06.770: V/NvAudioALSA(83): Latency: 92879
04-15 13:30:06.770: V/NvAudioALSA(83): Period Time: 23219
04-15 13:30:06.770: V/NvAudioALSA(83): Periods: 4
04-15 13:30:07.060: V/NvAudioALSA(83): Initialized ALSA PLAYBACK device music
04-15 13:30:09.550: D/ButtonBookActivity(1238): video completed
答案 0 :(得分:1)
This可能与Android音频延迟问题有关。 对音频文件的start()调用需要一些时间,然后才能从扬声器中发出声音。也许这也适用于视频,媒体播放器需要一段时间才能显示任何视频帧。
所以可能你无能为力。