Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-1028] Android: Implement AudioRecorder (Parity) #9067

Merged
merged 8 commits into from Jul 31, 2017

Conversation

ypbnv
Copy link
Contributor

@ypbnv ypbnv commented May 17, 2017

JIRA: https://jira.appcelerator.org/browse/TIMOB-1028

Description:
Base implementation of the AudioRecorder. In order to have play/pause functionality on API 22 and below and avoid formats that are not supported on some vendors' Android implementations currently it records uncompressed audio data in WAV format.

Basic test code:

var window = Ti.UI.createWindow();
var recordStart = Ti.UI.createButton({title:'Start', top:10});
var recordPause = Ti.UI.createButton({title:'Pause', top:60});
var recordStop = Ti.UI.createButton({title:'Stop', top:110});
var recordPlay = Ti.UI.createButton({title:'Play', top:160});
var audioRecorder = Ti.Media.createAudioRecorder();
var record;
var audioPlayer;

window.addEventListener('open', function (e) {
    Ti.API.info(Ti.Media.canRecord);
    if (!Ti.Media.hasAudioRecorderPermissions()) {
        Ti.Media.requestAudioRecorderPermissions(function (e) {
                    if (e.success) {
                        window.add(recordStart);
                    }
                });
    } else {
        window.add(recordStart);
    }
});

recordStart.addEventListener('click', function (e) {
    audioRecorder.start();
});

recordPause.addEventListener('click', function (e) {
    if (audioRecorder.getPaused()) {
        recordPause.setTitle('Pause');
        audioRecorder.resume()
    } else {
        recordPause.setTitle('Resume');
        audioRecorder.pause();
    }
});

recordStop.addEventListener('click', function (e) {
    record = audioRecorder.stop();
    Ti.API.info(record.getNativePath());
});

recordPlay.addEventListener('click', function (e) {
    audioPlayer = Ti.Media.createAudioPlayer({url:record.getNativePath()});
    audioPlayer.start();
});

window.add(recordPause);
window.add(recordStop);
window.add(recordPlay);

window.open();

Edit: Changed permissions methods' names in the test case to match the latest update.

@ypbnv ypbnv added this to the 6.2.0 milestone May 17, 2017
@ypbnv ypbnv requested a review from garymathews May 17, 2017 12:07
@ypbnv ypbnv added the android label May 17, 2017
@hansemannn hansemannn changed the title [TIMOB-1028] Implement AudioRecorder [TIMOB-1028] Android: Implement AudioRecorder (Parity) May 17, 2017
Copy link
Collaborator

@hansemannn hansemannn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change the docs to include the android platform in the platforms: key, where ever an API is available cross-platform now. Also add docs for the Android-only ones. Thank you!

ypbnv added 2 commits May 23, 2017 15:44
Change two methods' names to match the update for iOS from 6.1.0.
Change docs to include the added methods.
@ypbnv
Copy link
Contributor Author

ypbnv commented May 23, 2017

@hansemannn Changed the docs to include the new methods. Also renamed two of them (methods) to match the update from iOS.

@ypbnv
Copy link
Contributor Author

ypbnv commented May 23, 2017

Fixed the names.

@lokeshchdhry
Copy link
Contributor

FR Passed.

With proper permissions, the audio recorder's record, pause, play, stop works as expected.

  1. Checked by recording audio, stopping & playing it.
  2. Recording audio, pausing , recording again , stopping & playing.

Studio Ver: 4.9.1.201707200100
SDK Ver: 6.2.0 local build
OS Ver: 10.12.3
Xcode Ver: Xcode 8.3.3
Appc NPM: 4.2.9
Appc CLI: 6.2.3-21
Ti CLI Ver: 5.0.14
Alloy Ver: 1.9.13
Node Ver: 6.10.1
Java Ver: 1.8.0_101
Devices: ⇨ motorola XT1033 --- Android 4.4.4 , Nexus 5 -- Android 6.0.0
⇨ google Nexus 6P --- Android 7.1.1

@lokeshchdhry lokeshchdhry merged commit b4b46ff into tidev:master Jul 31, 2017
@ypbnv ypbnv modified the milestones: 7.0.0, 6.2.0 Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants