apache / apache/cordova-plugin-media

Live streams (over http, like web radio) don't play on iOS

Open
#324 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
391
Forks
762
PR merge metrics
No merged PRs in 30d

Description

# Bug Report

## Problem

### What is expected to happen?

`new Media('http://example.com/finite.mp3');` plays a sound from the internet,
`new Media('http://example.com/infinite-radio-live.mp3');` should play a live streaming sound.

### What does actually happen?

I see a status update to 2 (`MEDIA_RUNNING`), but there is no sound.

## Information

I've tried different radio stations (servers), protocols (http(s)) and formats (mp3, aac) to no avail.

### Command or Code

I have made a Minimal Reproduction Repo, originally in the probably unrelated issue #242 (OP mentions Android):
https://github.com/bikubi/cordova-plugin-media-mwe

I have since found the issue and a possible fix: [player.automaticallyWaitsToMinimizeStalling](https://developer.apple.com/documentation/avfoundation/avplayer/1643482-automaticallywaitstominimizestal) has to be `true` -- which makes sense with live streaming ("let it buffer").
I have implemented it as a proof of concept: https://github.com/bikubi/cordova-plugin-media/commit/591a7772b38e51f5832cb0582a5248caae207587
...and have my MRR use it [in branch `hotfix`](https://github.com/bikubi/cordova-plugin-media-mwe/tree/hotfix).
I'd fashion a PR, but am not sure where to put my fix (and how, this was my first line of ObjectiveC (?)), especially how to apply it only when the url is a live stream. There's no way to tell by the URL, so I guess it would have to be an extra parameter.

### Environment, Platform, Device

* iOS 15.1 on iPad
* 12.3.1 on an iPhone SE
* 15.0 in an iPhone 13 emulator.

### Version information

cordova 10.0.0
cordova-ios 6.2.0
cordova-plugin-file 6.0.2
cordova-plugin-whitelist 1.3.5
XCode 13.1 on macOS 11.6

## Checklist

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked proof-of-concept commit and the minimal reproduction repository's hotfix branch, then inspect where the iOS AVPlayer is configured. Confirm the behavior with the live-stream examples and finite MP3 example; done means HTTP live streams play on iOS without breaking finite media playback.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, objective-c
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.