apache / apache/cordova-plugin-media

Ionic Capacitor iOs: Media create INVALID (https url)

Open
#330 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
391
Forks
762
PR merge metrics
No merged PRs in 30d

Description

Hello and thank you for your awesome work !

# Bug Report

## Problem

On iOs, the song is not playing and i got an error on the Xcode's console. I create my media with an https URL where i get my audio file (it can be a .mp3 or a .wav file).

### What is expected to happen?

It should be playing the song, it works like a charm on Android.

### What does actually happen?

I got this error on the Xcode's console (i suppose it is related to why it's not working):

```
To Native Cordova -> Media release Media1406211762 ["options": [31e0d8f6-8bc9-bef4-c05c-029d1002b2f9]]
To Native Cordova -> Media create INVALID ["options": [ed2b3395-21d6-381f-0caf-070428409a48, http://viny.openstudio-lab.com/post/file/d45b1000-289f-4f5e-9a3d-c888332d78cd]]
2022-02-02 10:04:29.064381+0100 App[35121:1018948] Will use resource 'http://viny.openstudio-lab.com/post/file/d45b1000-289f-4f5e-9a3d-c888332d78cd' from the Internet.
⚡️ [log] - http://viny.openstudio-lab.com/post/file/d45b1000-289f-4f5e-9a3d-c888332d78cd
To Native Cordova -> Media startPlayingAudio INVALID ["options": [ed2b3395-21d6-381f-0caf-070428409a48, http://viny.openstudio-lab.com/post/file/d45b1000-289f-4f5e-9a3d-c888332d78cd, {
playAudioWhenScreenIsLocked = 0;
}]]

2022-02-02 10:24:58.431168+0100 App[50328:1066952] [plugin] AddInstanceForFactory: No factory registered for id F8BB1C28-BAE8-11D6-9C31-00039315CD46
2022-02-02 10:24:58.840417+0100 App[50328:1066959] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2022-02-02 10:24:58.859793+0100 App[50328:1066952] Playing audio sample 'http://viny.openstudio-lab.com/post/file/d45b1000-289f-4f5e-9a3d-c888332d78cd'
2022-02-02 10:24:58.943981+0100 App[50328:1066952] Duration is infifnite (TYPO !), setting it to -1
2022-02-02 10:24:58.944771+0100 App[50328:1066952] Playing stream with AVPlayer & default rate
```

### Command or Code

There is my url where i get the audio file: https://api.viny.club/post/file/47678658-88ab-4f6e-97f1-31d65b4cf152

My code:

```
import { Media, MediaObject } from '@ionic-native/media/ngx';

export class MediaService {
file: MediaObject;

constructor(private media: Media, ...){}

initMedia(fileId) {
this.file = this.media.create(fileUrl);

this.file.onStatusUpdate.subscribe((status) => {
...
// status 2 is detected but NO SOUND is played
// status 3 detected too, status 1 and 4 not detected
});

this.playMedia();
}

playMedia(): void {
if (this.file instanceof MediaObject) { // not necessary but for safety
this.file.play({ playAudioWhenScreenIsLocked: false }); // i tried without the ios option too
}
}
}
```

### Environment, Platform, Device

Ionic + Capacitor / iOs / emulator iPhone on Xcode (tried on iPhone 11 and 12).

### Version information

"@ionic-native/media": "^5.36.0", // tried with the last version of awesome cordova same result
"cordova-plugin-media": "^5.0.4"
"@capacitor/core": "^3.2.5"
"@capacitor/ios": "3.2.5"
"@ionic/angular": "^5.5.2",
dev:
"@angular/cli": "12.1.4"
"@capacitor/cli": "^3.3.2",

## 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 with the MediaService code using @ionic-native/media/ngx and reproduce the https audio case on iOS while reviewing the Xcode console output. Trace the cordova-plugin-media create and play path through the iOS implementation and AVPlayer logs. Done means the reported remote .mp3 or .wav URL plays with sound on iOS without breaking Android behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.