Search code examples
androidcordovapermissionsphonegap

PhoneGap Android permission issue for audio streaming


Almost finished my app with phonegap I did developed the app on iOS and I now need to export and generate apk for Android

Is v2 app of a couple of year old app I'm using adobe phonegap build to generate the apk

Older app work fine, when I download and install from play store it ask me if a grant "photo/multimedia elements/file" permission

and if I hit the play button streaming starts correctly, on new app it won't play the audio stream and when i install the app from dropbox it won't stream the audio

I'm using a OnePlus 6t as a test device

to start audio stream I use this code ( ad I did in previous version )

myaudio = new Audio('http://mystream.net:1935/live/myapp.stream/playlist.m3u8');
myaudio.id = 'playerMyAdio';
myaudio.play()

I try to add

<preference name="android.permission.INTERNET" value="none" />
<preference name="android.permission.MEDIA_CONTENT_CONTROL" value="none" />

as found in other question but it doesn't work

phonegap -v returns 8.2.2

this is my config.xml, I guess is a permission issue

<?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>

Solution

  • code was correct, the issue was on shoutcast server, stream was in some format that could not be use by Android but can be use from iOS