我几乎用phonegap完成了我的应用 我确实在iOS上开发了该应用,现在我需要导出并为Android生成APK
是数年前使用的应用程序的v2应用程序 我正在使用Adobe Phonegap构建来生成apk
较旧的应用程序运行正常,当我从游戏商店下载并安装时,它询问我是否授予“照片/多媒体元素/文件”权限
如果我按下播放按钮,则流媒体播放将正确启动,在新应用程序上,它将无法播放音频流;当我从保管箱安装应用程序时,它将无法流送音频
我正在使用OnePlus 6t作为测试设备
要开始播放音频流,请使用以下代码(我在先前版本中做过广告)
myaudio = new Audio('http://mystream.net:1935/live/myapp.stream/playlist.m3u8');
myaudio.id = 'playerMyAdio';
myaudio.play()
我尝试添加
<preference name="android.permission.INTERNET" value="none" />
<preference name="android.permission.MEDIA_CONTENT_CONTROL" value="none" />
如在其他问题中发现的那样,但这不起作用
phonegap -v返回8.2.2
这是我的config.xml,我想是权限问题
<?xml version='1.0' encoding='utf-8'?>
<widget id="it.myapp.app" version="2.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>myapp</name>
<description>
myapp
</description>
<author email="info@myapp.com" href="http://www.myapp.com">
MyAPP
</author>
<content src="index.html" />
<preference name="Orientation" value="portrait" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="19" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashScreen" value="splash" />
<preference name="SplashScreenDelay" value="100" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="StatusBarStyle" value="lightcontent" />
<platform name="android">
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="android.permission.INTERNET" value="none" />
<preference name="android.permission.MEDIA_CONTENT_CONTROL" value="none" />
</platform>
<platform name="android">
<icon qualifier="ldpi" src="res/icons/android/icon-36-ldpi.png" />
<icon qualifier="mdpi" src="res/icons/android/icon-48-mdpi.png" />
<icon qualifier="hdpi" src="res/icons/android/icon-72-hdpi.png" />
<icon qualifier="xhdpi" src="res/icons/android/icon-96-xhdpi.png" />
<icon qualifier="xxhdpi" src="res/icons/android/icon-144-xxhdpi.png" />
<icon qualifier="xxxhdpi" src="res/icons/android/icon-192-xxxhdpi.png" />
<splash qualifier="ldpi" src="res/screens/android/screen-ldpi-portrait.png" />
<splash qualifier="mdpi" src="res/screens/android/screen-mdpi-portrait.png" />
<splash qualifier="hdpi" src="res/screens/android/screen-hdpi-portrait.png" />
<splash qualifier="xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />
</platform>
<platform name="ios">
<icon height="20" platform="ios" src="res/icons/ios/icon-20.png" width="20" />
<icon height="40" platform="ios" src="res/icons/ios/icon-20@2x.png" width="40" />
<icon height="60" platform="ios" src="res/icons/ios/icon-20@3x.png" width="60" />
<icon height="29" platform="ios" src="res/icons/ios/icon-29.png" width="29" />
<icon height="58" platform="ios" src="res/icons/ios/icon-29@2x.png" width="58" />
<icon height="87" platform="ios" src="res/icons/ios/icon-29@3x.png" width="87" />
<icon height="80" platform="ios" src="res/icons/ios/icon-40@2x.png" width="80" />
<icon height="120" platform="ios" src="res/icons/ios/icon-40@3x.png" width="120" />
<icon height="50" platform="ios" src="res/icons/ios/icon-50.png" width="50" />
<icon height="100" platform="ios" src="res/icons/ios/icon-50@2x.png" width="100" />
<icon height="57" platform="ios" src="res/icons/ios/icon-57.png" width="57" />
<icon height="114" platform="ios" src="res/icons/ios/icon-57@2x.png" width="114" />
<icon height="180" platform="ios" src="res/icons/ios/icon-60@3x.png" width="180" />
<icon height="72" platform="ios" src="res/icons/ios/icon-72.png" width="72" />
<icon height="144" platform="ios" src="res/icons/ios/icon-72@2x.png" width="144" />
<icon height="76" platform="ios" src="res/icons/ios/icon-76.png" width="76" />
<icon height="152" platform="ios" src="res/icons/ios/icon-76@2x.png" width="152" />
<icon height="167" platform="ios" src="res/icons/ios/icon-83.5@2x.png" width="167" />
<icon height="1024" platform="ios" src="res/icons/ios/icon-1024.png" width="1024" />
<splash height="480" platform="ios" src="res/screens/ios/screen-iphone-portrait.png" width="320" />
<splash height="960" platform="ios" src="res/screens/ios/screen-iphone-portrait-2x.png" width="640" />
<splash height="1136" platform="ios" src="res/screens/ios/screen-iphone-portrait-568h-2x.png" width="640" />
<splash height="1334" platform="ios" src="res/screens/ios/screen-iphone-portrait-667h.png" width="750" />
<splash height="2208" platform="ios" src="res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />
<splash height="1024" platform="ios" src="res/screens/ios/screen-ipad-portrait.png" width="768" />
<splash height="2048" platform="ios" src="res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash height="320" platform="ios" src="res/screens/ios/screen-iphone-landscape.png" width="480" />
<splash height="640" platform="ios" src="res/screens/ios/screen-iphone-landscape-2x.png" width="960" />
<splash height="640" platform="ios" src="res/screens/ios/screen-iphone-landscape-568h-2x.png" width="1136" />
<splash height="750" platform="ios" src="res/screens/ios/screen-iphone-landscape-667h.png" width="1334" />
<splash height="1242" platform="ios" src="res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />
<splash height="768" platform="ios" src="res/screens/ios/screen-ipad-landscape.png" width="1024" />
<splash height="1536" platform="ios" src="res/screens/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash height="2732" platform="ios" src="res/screens/ios/Default@2x~universal~anyany.png" width="2732" />
</platform>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-x-socialsharing" source="npm" version="5.4.0" />
<plugin name="nl.kingsquare.cordova.background-audio" spec="^1.0.1" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
<engine name="browser" spec="^5.0.4" />
<engine name="ios" spec="^4.5.5" />
<engine name="android" spec="~7.1.4" />
</widget>
答案 0 :(得分:1)
OnePlus 6T似乎正在运行当前版本的Android OS,默认情况下会限制HTTP
流量。
对于Cordova,您需要像这样引用network_security_config.xml
:
<platform name="android">
<edit-config xmlns:android="http://schemas.android.com/apk/res/android" file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<resource-file src="network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
</platform>
network_security_config.xml
将需要此一项排除:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>mystream.net</domain>
</domain-config>
</network-security-config>
答案 1 :(得分:0)
根据Android Documentation MEDIA_CONTENT_CONTROL,第三方应用程序无法使用。
bar_1 | curl: (6) Could not resolve host: foo bar_1 | curl: (6) Could not resolve host: foo ...
已在API级别19中添加
MEDIA_CONTENT_CONTROL
允许应用程序知道正在播放什么内容并控制其内容 播放。
由于媒体的隐私,不能由第三方应用程序使用 消费
恒定值:
public static final String MEDIA_CONTENT_CONTROL
并且没有替代品。您也可以选中此How to get android permission of android.Manifest.permission.MEDIA_CONTENT_CONTROL
答案 2 :(得分:0)
代码正确,问题出在shoutcast服务器上,流采用某种格式,Android无法使用,但可以在iOS上使用