apache / apache/cordova-plugin-media

File Size coming as 0 in android 11

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

Description

# Bug Report
On Android below 11 works fine and size also comes perfect but on android 11 size always comes as 0
## Problem

### What is expected to happen?
It should record the file and should be able to show file size more than 0

### What does actually happen?
Not working in android 11

## Information

Any more information needed please feel free to ask.

### Command or Code

recordAudio(){
let extension ='wav' // 'm4a' 'mp3'

this.file.createFile(this.file.dataDirectory, '111file.'+extension, true).then(() => {
this.myFile = this.media.create(this.file.dataDirectory+'111file.'+extension,);
console.log('filepath',this.file.dataDirectory+'111file.'+extension)
console.log("this.myFile",this.myFile)
this.myFile.startRecord();
alert('started recording')
}).catch(err=>{
console.log('createFile err',err)
});

async stopRecording(){
let extension = 'wav'// 'm4a' 'mp3'
alert('stop called')
this.myFile.stopRecord()

setTimeout(() => {
let duration = this.myFile.getDuration();
console.log(duration);
console.log("this.myFile2",this.myFile)

this.file.readAsDataURL(this.file.dataDirectory, '111file.'+extension).then(res=>{
console.log("checkFile res",res)
let url = this.file.dataDirectory+'111file.'+extension
this.file.resolveLocalFilesystemUrl(url).then(fileEntry => {
fileEntry.getMetadata((metadata) => {
console.log("size",metadata.size);//metadata.size is the size in bytes
})
})
}).catch(err=>{
console.log("checkFile err",err)
})
}, 1000);
}

### Environment, Platform, Device

Device used: Oneplus 9R
OS: Android 11

### Version information

Project based on ionic 3
cordova 10.0.0
ionic 5.4.13
"cordova-plugin-file": "^6.0.2",
"cordova-android": "8.1.0",
"@ionic-native/media": "^4.20.0",
"cordova-plugin-media": "^5.0.3",
"typescript": "2.8.4"

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

Reproduce the issue with the recordAudio and stopRecording entry points on the listed Android 11 device and plugin versions. Trace the file creation, media recording, and metadata.size checks, then compare the result with Android versions below 11. Done means the recorded file is created and its reported size is greater than zero on Android 11.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, typescript
Domain
audio-video-rtc, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.