我测试了一个播放视频的 Android 应用程序。问题是视频播放失败并出现未知错误:
MediaPlayer(20533): Error (1,-2147483648)
申请代码:
// Place the video view.
mVideoView = (VideoView) findViewById(R.id.surface_view);
// Retrieve the video path.
path = getIntent().getStringExtra(PATH);
Log.i(TAG, "Play the file : " + path);
// Set the video to play.
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
// Start the video play.
mVideoView.start();
提供视频的 Web 服务器是带有 PHP 5 的 Apache2。
HTTP 请求:
首先:
GET /.../hsf6bfs9/android.mp4 HTTP/1.1
Host: site.com
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.2.2)
Accept-Encoding: gzip,deflate
HTTP/1.1 200 OK
Date: Tue, 04 Jun 2013 16:57:42 GMT
Server: Apache
Cache-Control: public
Content-Transfer-Encoding: binary
Content-Disposition: inline; filename="android.mp4"
Accept-Ranges: bytes
Content-Range: bytes 0-5245532/5245533
Content-Length: 5245533
Keep-Alive: timeout=30, max=100
Connection: Keep-Alive
Content-Type: video/mp4
第二:
GET /.../hsf6bfs9/android.mp4 HTTP/1.1
Host: site.com
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.2.2)
Accept-Encoding: gzip,deflate
Range: bytes=4927056-
HTTP/1.1 206 Partial Content
Date: Tue, 04 Jun 2013 16:57:45 GMT
Server: Apache
X-Mod-H264-Streaming: version=2.2.7
Content-Length: 318511
Last-Modified: Tue, 04 Jun 2013 16:57:43 GMT
ETag: "36bc00b-500a5d-4de56facaefc0;5245567"
Accept-Ranges: bytes
Content-Range: bytes 4927056-5245566/5245567
Keep-Alive: timeout=30, max=100
Connection: Keep-Alive
Content-Type: video/mp4
失败前的最后一个:
GET /.../hsf6bfs9/android.mp4 HTTP/1.1
Host: site.com
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.2.2)
Accept-Encoding: gzip,deflate
Range: bytes=3591808430-
HTTP/1.1 416 Requested Range Not Satisfiable
Date: Tue, 04 Jun 2013 16:57:47 GMT
Server: Apache
Keep-Alive: timeout=30, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>416 Requested Range Not Satisfiable</title>
</head><body>
<h1>Requested Range Not Satisfiable</h1>
<p>None of the range-specifier values in the Range
request-header field overlap the current extent
of the selected resource.</p>
</body></html>
找到的日志:
06-05 10:23:06.577: I/NuCachedSource2(161): new range: offset= 4927056
06-05 10:23:07.618: I/NuCachedSource2(161): ERROR_END_OF_STREAM
06-05 10:23:07.618: I/NuCachedSource2(161): new range: offset= 3591808430
06-05 10:23:07.618: I/ChromiumHTTPDataSource(161): Reconnecting...
06-05 10:23:07.638: D/overlay(158): Unset pipe=RGB1 dpy=0;
06-05 10:23:07.788: I/ChromiumHTTPDataSourceSupport(161): We requested a content range, but server didn't support that. (responded with 416)
06-05 10:23:07.788: I/ChromiumHTTPDataSource(161): Reconnect failed w/ err 0xffffffe0
06-05 10:23:07.788: E/MediaPlayer(19641): error (1, -2147483648)
你知道这个问题吗?谢谢!