我正在ionic4上写一个流式应用程序,我正在我的手机上测试它,但是我的手机不会打开http链接.
控制台:
GET http://131.173.8.23/mjpg/video.mjpg net::ERR_CLEARTEXT_NOT_PERMITTED
我读到你可以绕过添加一个network_security_config.xml文件,但是你知道什么.不管用!(但在我的浏览器上工作正常)
有人知道吗?
我的代码:
(network_security_config.xml)
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost:8100</domain>
<domain>131.173.8.23:80</domain>
</base-config>
</network-security-config>(AndroidManifest)
<?xml version='1.0' encoding='utf-8'?>
<manifest
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.0.1"
package="io.ionic.starter"
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" />
<application
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:configChanges="orientation|screenSize" android:label="Simple Audio Stream" android:name="com.hutchind.cordova.plugins.streamingmedia.SimpleAudioStream" />
<activity android:configChanges="orientation|screenSize" android:label="Simple Video Stream" android:name="com.hutchind.cordova.plugins.streamingmedia.SimpleVideoStream" />
</application>
</manifest>(home.page.html)
<ion-header>
<ion-toolbar>
<ion-title>
CameraLux
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-grid>
<ion-row>
<ion-col>
<video width="250" height="160" (click)="startVideo()" autoplay>
<source src="http://131.173.8.23:80/mjpg/video.mjpg"/>
</video>
</ion-col>
<ion-col>
<video width="250" height="160" autoplay>
<source src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"/>
</video>
</ion-col>
<ion-col>
<video width="250" height="160" (click)="startVideo()" autoplay>
<source src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"/>
</video>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<video width="250" height="160" (click)="startVideo()" autoplay>
<source src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"/>
</video>
</ion-col>
<ion-col>
<video width="250" height="160" (click)="startVideo()" autoplay>
<source src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"/>
</video>
</ion-col>
<ion-col>
<video width="250" height="160" (click)="startVideo()" autoplay>
<source src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"/>
</video>
</ion-col>
</ion-row>
</ion-grid>
<br/>
<br/>
<br/>
<br/>
</ion-content>发布于 2019-11-12 18:21:05
android:networkSecurityConfig="@xml/network_security_config" 不适用于android:usesCleartextTraffic="true"
所以在你的config.xml中应该只有
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
</edit-config>不是两者都有
发布于 2020-01-24 09:47:35
添加
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
</edit-config>config.xml运行cordova platform rm android然后运行cordova platform add android
https://stackoverflow.com/questions/58821320
复制相似问题