HTML5视频播放器Android - PhoneGAP

时间:2017-04-27 00:52:24

标签: android ios cordova mobile html5-video

我是Android开发和混合移动应用程序的新手,但我需要在混合移动应用程序中播放视频。我正在使用HTML5原生视频标签,我可以确认它在IOS上运行良好。

Android手机上发生的情况是当您按下播放按钮时,屏幕左侧空白,我可以在日志中看到以下几行:

04-27 10:25:58.208 1655-2941/system_process I/MediaFocusControl:  AudioFocus  requestAudioFocus() from android.media.AudioManager@2803c75org.chromium.media.MediaPlayerListener@a83940a req=3flags=0x0
04-27 10:25:58.210 3082-3082/com.example W/MediaPlayer: Couldn't open file on client side; trying server side: java.io.FileNotFoundException: No content provider: https://s3-ap-southeast-2.amazonaws.com/demovideos/video.mp4
04-27 10:25:58.217 1361-3333/? D/NuPlayer: onSetVideoSurface(0xf3d20100, no video decoder)
04-27 10:25:58.402 3082-3241/com.example E/chromium: [ERROR:gles2_cmd_decoder_autogen.h(1642)] [GroupMarkerNotSet(crbug.com/242999)!:F89A7C82A67F0000]GL ERROR :GL_INVALID_OPERATION : GetIntegerv: <- error from previous GL command
04-27 10:25:58.647 1361-3334/? I/SampleTable: There are reordered frames present.
04-27 10:25:58.649 1361-3333/? D/NuPlayerDriver: notifyListener_l(0xf3d45540), (5, 320, 240)
04-27 10:25:58.650 1361-3333/? D/NuPlayerDriver: notifyListener_l(0xf3d45540), (3, 17, 0)
04-27 10:25:58.954 1361-3339/? I/NuCachedSource2: caching reached eos.
04-27 10:25:59.649 1361-3333/? D/NuPlayerDriver: notifyListener_l(0xf3d45540), (3, 100, 0)
04-27 10:25:59.649 1361-3333/? D/NuPlayerDriver: notifyListener_l(0xf3d45540), (1, 0, 0)
04-27 10:25:59.745 3082-3082/com.example D/MediaPlayer: setSubtitleAnchor in MediaPlayer
04-27 10:25:59.777 1361-1652/? D/NuPlayerDriver: start(0xf3d45540), state is 4, eos is 0
04-27 10:25:59.777 1361-3333/? I/GenericSource: start

我查看了stackoverflow.com并阅读了所有评论和建议,

  • 设置WebChrome客户端和

  • 在AndroidManifest.xml中启用硬件加速器

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="30306" android:versionName="3.3.6" android:windowSoftInputMode="adjustPan" package="com.example" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
    <application android:allowBackup="false" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:name="com.example.MyApplication">
        ... 
        ...
        ...
    </application>
</manifest>

我还检查了视频的内容类型和大小(1MB):

http GET https://s3-ap-southeast-2.amazonaws.com/demovideos/video.mp4

HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 1065903
Content-Type: video/mp4
Date: Thu, 27 Apr 2017 00:00:58 GMT
ETag: "c866e6fe66f12efed2df2db39d9b2f67"
Last-Modified: Thu, 27 Apr 2017 00:00:55 GMT
Server: AmazonS3
x-amz-id-2: xxxxxxxxxxxxx
x-amz-request-id: xxxxxxxxxxx

节点:   - 该应用程序使用HTML5编写,并使用PhoneGAP Wrapped。

如果你能告诉我为什么它不起作用,我真的很感激。请不要发送Stackoverflow链接,我已经尝试过所有这些链接。

提前多多感谢。

2 个答案:

答案 0 :(得分:0)

看看这个答案:

https://stackoverflow.com/a/43559947/7837081

如果您尝试在模拟器上使用视频标记,我们发现存在问题。 Android版本的视频拍摄也存在问题=&lt; 4.4.2

答案 1 :(得分:0)

感谢您的帮助,我们发现有人通过调用代码来禁用代码中的硬件加密:

this.setLayerType(View.LAYER_TYPE_SOFTWARE,null);

https://developer.android.com/guide/topics/graphics/hardware-accel.html