apache / apache/cordova-plugin-media

Saving recording file not working on Samsung devices

Open
#188 0 comments 0 reactions 0 assignees View on GitHub
platform: android support
Dominant language
JavaScript
Stars
391
Forks
762
PR merge metrics
No merged PRs in 30d

Description

Hello,

We use this plugin to record audio fragments and save them in our app. On some phones we are unfortunately unable to save the recorded audio fragment in our app. The issue is reproducable on all Samsung devices we tried, ranging from Android 4.4 to 7.0.

What happens: We initiate recording and finish creating an audio fragment. Then, we click a paperclip icon in the Samsung recording app, but the audio fragment is never taken back into our app. Why does this happen? Is there a way to properly troubleshoot this?

It works fine on Huawei P10 (Android 8.0.0) and Sony Xperia Z3 (Android 6.0)

What worries me is that every brand of devices seem to have their own recording app, with different implementations. Is there a way to standardize the recording app or create a buildin recording system, without requiring the users to install another app? If so, I'd love to hear about that.

PS: I saw there's also a [cordova-plugin-media-capture](https://github.com/apache/cordova-plugin-media-capture). What's the difference between this one and that one?

Many thanks in advance!

Here's the code that is responsible for our recordings:

.controller('RecordingCtrl', function ($scope, $ionicPlatform, $cordovaFile, $timeout, database) {
var recordingDirectory;
var rootDirectory;
$scope.entries = [];
$scope.disablePlaying = false;
$scope.renaming = false;
$scope.soundplaying = false;
$scope.alertNameChange = false;

$scope.$on('$ionicView.enter', function () {
loadRecordings();
});
$ionicPlatform.ready(function () {
var extension = (ionic.Platform.isIOS()) ? '.wav' : '.amr';
recordingDirectory = "helpy/recordings";

rootDirectory = cordova.file.applicationStorageDirectory;
rootDirectory += (ionic.Platform.isIOS()) ? 'Library/' : 'files/';
$scope.recordAudio = function () {
var captureError = function (e) {
console.dir('captureError', e);
};
var captureSuccess = function (mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i++) {
$cordovaFile.checkDir(rootDirectory, recordingDirectory)
.then(function () {
}, function () {
$cordovaFile.createDir(rootDirectory, "helpy", false);
$cordovaFile.createDir(rootDirectory, recordingDirectory, false);
});

var filename = $scope.filename = 'opname_' + Math.floor(Date.now() / 1000);
var temp_dir = (ionic.Platform.isIOS()) ? cordova.file.tempDirectory : mediaFiles[i].fullPath.replace(mediaFiles[i].name, '');
var extension = mediaFiles[i].name.split('.')[1];

console.log('temporary directory: ' + temp_dir);

$cordovaFile.moveFile(temp_dir, mediaFiles[i].name, rootDirectory + recordingDirectory, filename + "." + extension)
.then(function () {
database.add('Recordings', {0: filename, 1: 0}).then(function () {
});
$scope.entries.push({active: 0, name: filename});
$scope.alertNameChange = true;
}, function (error) {
console.dir(error);
});
}
};

navigator.device.capture.captureAudio(captureSuccess, captureError);
};

Contributor guide

Open the contributing guide

Research direction

Start at navigator.device.capture.captureAudio in the supplied RecordingCtrl code and reproduce the behavior on Samsung Android 4.4–7.0, comparing the Huawei and Sony results. Trace the returned mediaFiles path and the subsequent $cordovaFile.moveFile call, using the captureError and moveFile error output to identify whether handoff or file movement fails. Done means a confirmed cause and a documented fix or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
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.