apache / cordova-plugin-media

Apache Cordova Media Plugin
https://cordova.apache.org/
Apache License 2.0
388 stars 765 forks source link

Can't get icecast streams to work on iOS #256

Open nickh364 opened 5 years ago

nickh364 commented 5 years ago

Bug Report

Problem

Not playing icecast streams. We have 3 icecast streams for our radio stations and none of them work.

What is expected to happen?

To play the icecast stream.

What does actually happen?

Logs whats below but plays nothing.

Log From iPad 2019-09-30 13:28:41.442874-0500 AFR[777:681160] Play url: https://mediaserver3.afa.net:8443/talk.mp3 2019-09-30 13:28:41.444745-0500 AFR[777:681160] Will use resource 'https://mediaserver3.afa.net:8443/talk.mp3' from the Internet. 2019-09-30 13:28:41.456505-0500 AFR[777:681160] THREAD WARNING: ['Media'] took '11.751953' ms. Plugin should use a background thread. 2019-09-30 13:28:41.468467-0500 AFR[777:681378] Playing audio sample 'https://mediaserver3.afa.net:8443/talk.mp3' 2019-09-30 13:28:42.399515-0500 AFR[777:681378] Duration is infifnite, setting it to -1 2019-09-30 13:28:42.399815-0500 AFR[777:681378] Playing stream with AVPlayer & default rate 2019-09-30 13:28:42.413091-0500 AFR[777:681160] media status: 2

Log from simulator 2019-09-30 13:13:05.300506-0500 AFR[41459:10012960] Play url: https://mediaserver3.afa.net:8443/music.mp3 2019-09-30 13:13:05.305044-0500 AFR[41459:10012960] Will use resource 'https://mediaserver3.afa.net:8443/music.mp3' from the Internet. 2019-09-30 13:13:05.308447-0500 AFR[41459:10013235] Playing audio sample 'https://mediaserver3.afa.net:8443/music.mp3' 2019-09-30 13:13:05.368662-0500 AFR[41459:10013268] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection 2019-09-30 13:13:05.672912-0500 AFR[41459:10013235] Duration is infifnite, setting it to -1 2019-09-30 13:13:05.673044-0500 AFR[41459:10013235] Playing stream with AVPlayer & default rate 2019-09-30 13:13:05.676718-0500 AFR[41459:10013236] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection 2019-09-30 13:13:05.677978-0500 AFR[41459:10014900] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection 2019-09-30 13:13:05.680213-0500 AFR[41459:10014928] AudioObjectRemovePropertyListener: no object with given ID 0 2019-09-30 13:13:05.680337-0500 AFR[41459:10014928] AudioObjectRemovePropertyListener: no object with given ID 0 2019-09-30 13:13:05.680435-0500 AFR[41459:10014928] AudioObjectRemovePropertyListener: no object with given ID 0 2019-09-30 13:13:05.681402-0500 AFR[41459:10014928] AudioObjectRemovePropertyListener: no object with given ID 0 2019-09-30 13:13:05.681507-0500 AFR[41459:10014928] AudioObjectRemovePropertyListener: no object with given ID 0 2019-09-30 13:13:05.681628-0500 AFR[41459:10014928] AudioObjectRemovePropertyListener: no object with given ID 0 2019-09-30 13:13:05.686190-0500 AFR[41459:10012960] media status: 2 2019-09-30 13:13:05.697282-0500 AFR[41459:10013236] [] nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection 2019-09-30 13:13:07.256206-0500 AFR[41459:10015020] HALC_ProxyIOContext::IOWorkLoop: failed to send the final message to the server, Error: 0x10000003

Information

It works when we use a podcast URL but not when we use one of our icecast URLs. Here is one of our icecast URLs https://mediaserver3.afa.net:8443/music.mp3 I have also tried it as http and mp4 http://mediaserver3.afa.net:8000/music.mp3 https://mediaserver3.afa.net:8443/music.mp4

Command or Code

this.player = this.media.create(icecastUrl); this.player.play();

Environment, Platform, Device

Tried on iPad Air 2(iOS 13.1.1), iPhone 6(iOS 12.4.1) and iPhone 11 Sim (13.0.0)

Version information

Cordova CLI: 9.0.0 (cordova-lib@9.0.1) Cordova Platforms: iOS(5.0.1) Cordova Plugins: cordova-plugin-appavailability 0.4.2 "AppAvailability" cordova-plugin-background-download 0.0.2 "Background Download" cordova-plugin-device 2.0.2 "Device" cordova-plugin-dialogs 2.0.1 "Notification" cordova-plugin-file 6.0.1 "File" cordova-plugin-firebase-config 1.2.1 "cordova-plugin-firebase-config" cordova-plugin-google-analytics 1.8.6 "Google Universal Analytics Plugin" cordova-plugin-inappbrowser 3.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 3.1.2 "cordova-plugin-ionic-webview" cordova-plugin-media 5.0.3 "Media" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-socialsharing 5.4.4 "SocialSharing" cordova-plugin-x-toast 2.7.2 "Toast" cordova-sqlite-storage 3.2.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version" es6-promise-plugin 4.2.2 "Promise" nl.x-services.plugins.backgroundaudio 1.0.1 "BackgroundAudio" onesignal-cordova-plugin 2.4.6 "OneSignal Push Notifications"

Ionic Framework: ionic/angular 4.4.0 Ionic CLI: 4.12.0

OS: MacOS 10.14.6 Xcode: 11

Checklist

MarcelvanGastel commented 5 years ago

I have the same problem. Behaviour is: Stream is 'downloading', the native player in iOS used by this plugin is firing fine, but for some reason it's muted. It seemed to work fine in the past.

I'm currently downgrading my plugins, I will let you know if this solves it.

MarcelvanGastel commented 5 years ago

Yes, rolling back to 4.0.0 seems to solve the problem for now..

nickh364 commented 5 years ago

Yes, rolling back to 4.0.0 seems to solve the problem for now..

I ended up tracking down what broke it. It looks like it was broke in 5.0.3 with this code on line 270 of the CDVSound.m

if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10,0,0}]) {
    avPlayer.automaticallyWaitsToMinimizeStalling = NO;
}

I ended up changing that to the code below so it would work for our icecast streams and the podcasts would load faster. then before 5.0.3

if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10,0,0}] 
&& ![resourcePath hasPrefix:@"https://IcecastServerUrl"]) {
    avPlayer.automaticallyWaitsToMinimizeStalling = NO;
}

A better way to do it would probably be to send in a var in the on create to for something like isStream or something like that

RomainDev25 commented 4 years ago

Hello, we have the same issue on our app, stream icecast not play, but sound podcast yes. I comment part at line 270 and it's working. Thanks @nick364 ;)

netmikey commented 4 years ago

Http audio streaming like icecast is pretty ubiquitous nowadays, having this fail out-of-the-box is a bummer, so is there any chance @nickh364 's "fix" could make it into the official plugin (not with the icecast-server-prefix of course, but as a configurable option on the media object maybe)?

** Edit: I can confirm that this is actually a regression as of cordova-plugin-media v5.0.3. With 5.0.2, everything seems to work just fine. Looks like it has been introduced with #169.

andreas-aeschlimann commented 4 years ago

I just have implemented an Icecast stream into an Ionic app with this package and it works when I wait for a second before calling the play function:

    const mediaObject = this.media.create(url);
    timer(1000).subscribe(() => mediaObject.play());

I am not sure if this is relevant to this issue, but I thought it might help some other developers.

bikubi commented 2 years ago

looks like I came up with the same fix in #324 ... why hadn't I found this? *sigh*

netmikey commented 2 years ago

Fast-forward 2 years, I'm working on our app again, upgrading dependencies, wondering why audio isn't working, googling for a solution and finding my own comment in this thread. sigh, could this please be fixed @erisu ? The guys in this thread really did everything to minimize the work required for a fix...