用于音频流的PhoneGap Android权限问题

问题描述 投票:2回答:3

几乎完成了我的应用程序与phonegap我在iOS上开发了应用程序,我现在需要导出并生成apk for Android

是一个几年的应用程序的v2应用程序我正在使用adobe phonegap build来生成apk

较旧的应用程序工作正常,当我从Play商店下载并安装时,它问我是否授予“照片/多媒体元素/文件”权限

如果我点击播放按钮流正确启动,在新的应用程序上它将不播放音频流,当我从Dropbox安装应用程序时,它将不会流式传输音频

我正在使用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="[email protected]" 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/[email protected]" width="40" />
        <icon height="60" platform="ios" src="res/icons/ios/[email protected]" 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/[email protected]" width="58" />
        <icon height="87" platform="ios" src="res/icons/ios/[email protected]" width="87" />
        <icon height="80" platform="ios" src="res/icons/ios/[email protected]" width="80" />
        <icon height="120" platform="ios" src="res/icons/ios/[email protected]" 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/[email protected]" 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/[email protected]" width="114" />
        <icon height="180" platform="ios" src="res/icons/ios/[email protected]" 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/[email protected]" 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/[email protected]" width="152" />
        <icon height="167" platform="ios" src="res/icons/ios/[email protected]" 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>
android cordova permissions phonegap
3个回答
1
投票

OnePlus 6T似乎运行当前版本的Android操作系统,默认情况下限制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>

0
投票

根据Android Documentation,MEDIA_CONTENT_CONTROL不能被第三方应用程序使用。

MEDIA_CONTENT_CONTROL在API级别19中添加

public static final String MEDIA_CONTENT_CONTROL

允许应用程序知道正在播放的内容并控制其播放。

由于媒体消费的隐私,不供第三方应用程序使用

常数值:"android.permission.MEDIA_CONTENT_CONTROL"

这个没有替代品。你也可以查看这个How to get android permission of android.Manifest.permission.MEDIA_CONTENT_CONTROL


0
投票

代码是正确的,问题是在shoutcast服务器上,流是某种格式,Android无法使用,但可以从iOS使用

© www.soinside.com 2019 - 2024. All rights reserved.