Cordova + Android:拦截流媒体webm资源

时间:2015-08-22 03:49:41

标签: android cordova intercept

我在Android 4.4上使用Cordova v3.4.0。我的网络应用程序定义了webm流的视频标记元素。

<video src="https://stream.server.com:1234/video_rgb" type="video/webm"
</video>

我正在尝试拦截对stream.server.com:1234和一些auth标头的请求。添加标题后,我会以这种方式返回Web响应。

Cordova活动

this.appView.setWebViewClient(new CordovaWebViewClient(this, this.appView) {

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view, String url) {

            if (shouldIntercept(url)) {
                LOG.i(TAG, "Intercepting " + url + " request");
                return handleRequest(url);
            } else {
                return super.shouldInterceptRequest(view, url);
            }
        }
    });

// handleRequest()
httpGet = generateHttpGet(url, authHeaders); // Returns org.apache.http.client.methods.HttpGet
DefaultHttpClient client = new DefaultHttpClient();
httpResponse = client.execute(httpGet);
return new WebResourceResponse(contentTypeValue, encodingValue, responseInputStream);

请求成功通过,但视频从未呈现。当我点击播放时,没有任何反应。有时应用程序会挂起。 Android日志不会显示任何有用的内容,除了请求成功与content-type:video / webm和content length = -1。我不确定我在这里做错了什么。

注意:这适用于具有固定长度的webm视频或静态资产(如图像)。

感谢您的任何指示。

0 个答案:

没有答案