Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Changed play() and prepareRecordingAtPath() to use absolute paths to audio files #57

Merged
merged 1 commit into from
Mar 19, 2016

Conversation

wootwoot1234
Copy link
Contributor

Changed play() and prepareRecordingAtPath() to use absolute paths to audio files.

Added AudioUtils module for creating paths to files. AudioUtils has constants: MainBundlePath, CachesDirectoryPath, DocumentDirectoryPath, LibraryDirectoryPath. Since the constants are used in both play and record it seemed cleaner to create AudioUtils.

Fixed typo with encoding code, had "caf" as default AudioEncoding type but should be "ima4", "ima4" is the audio encoding for "caf" files.

Here's an example of how to use the new constants.

    var {AudioRecorder, AudioPlayer, AudioUtils} = require('react-native-audio');

    // for recording
    var options = {
        SampleRate: 16000.0,
        Channels: 1,
        AudioQuality: 'Medium',
        AudioEncoding: 'aac',
    };
    var audioPath = AudioUtils.DocumentDirectoryPath + '/filename.m4a';
    AudioRecorder.prepareRecordingAtPath(audioPath, options);

    // for playing
    var audioPath = AudioUtils.DocumentDirectoryPath + '/filename.m4a';
    AudioPlayer.play(audioPath);

…audio files.

Added AudioUtils module for creating paths to files.  AudioUtils has constants: MainBundlePath, CachesDirectoryPath, DocumentDirectoryPath, LibraryDirectoryPath.  Since the constants are used in both play and record it seemed cleaner to create AudioUtils.

Fixed typo with encoding code, had "caf" as default AudioEncoding type but should be "ima4", "ima4" is the audio encoding for "caf" files.

Here's an example of how to use the new constants.

        var options = {
            SampleRate: 16000.0,
            Channels: 1,
            AudioQuality: 'Medium',
            AudioEncoding: 'aac',
        };
        var audioPath = AudioUtils.DocumentDirectoryPath + '/filename.m4a';
        AudioRecorder.prepareRecordingAtPath(audioPath, options);
@jsierles
Copy link
Owner

AudioUtils is perfect - I wanted to do that anyway. It would be even better if this were a common library that other plugins could use. I thought about using react-native-fs but it may be too heavy a dependency.

Anyway I'll add docs about the breaking change, and we can bump to 1.0.0. If you can, could you look at updating the AudioExample project? If not I'll take a look.

jsierles added a commit that referenced this pull request Mar 19, 2016
Changed play() and prepareRecordingAtPath() to use absolute paths to audio files
@jsierles jsierles merged commit be556f5 into jsierles:master Mar 19, 2016
@345ml 345ml mentioned this pull request Mar 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants