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

File upload's type is GP, not mp4/m4a although file's tag is mp4/m4a, and can't play this audio from url #78

Closed
Hieutt1704 opened this issue Jun 17, 2019 · 6 comments · Fixed by #114

Comments

@Hieutt1704
Copy link

Hieutt1704 commented Jun 17, 2019

Version of react-native-audio-recorder-player: 2.1.2

Platforms you faced the error (IOS or Android or both?): both

React-native 0.59.5

@hyochan
Copy link
Owner

hyochan commented Jun 17, 2019

I hope you could provide more example to help you out.

@Hieutt1704
Copy link
Author

Here is audio's url: http://118.70.180.81:8055/UserAudio/74fca23d-fc54-4b5d-9213-1d220abaf22a/2019/6/1560826688hccqb0.m4a when i post the audio file recored. I converted this file to base64 and saw:
61719298_383691719162980_3339387727484289024_n
You need a tool dowload to dowload this file,that counld't be dowloaded from browser

@Hieutt1704
Copy link
Author

Hieutt1704 commented Jun 18, 2019

I tried react-native-audio and it worked perpectly

@hyochan
Copy link
Owner

hyochan commented Jun 22, 2019

@Hieutt1704 I hope you can provide us clearer example (maybe some code) so that I can do some work on improving our module.

@Hieutt1704
Copy link
Author

Hieutt1704 commented Jun 27, 2019

Here is the code record audio:

onStartRecord = async () => {

const result = await this.audioRecorderPlayer.startRecorder();

this.setState({ uri_audio: result, startRecord: true })

this.audioRecorderPlayer.addRecordBackListener(e => {

if (this.state.recordSecs == 12) {

this.onStopRecord();

Utils.showToast(I18n.t("limit_record"));

} else

this.setState({

recordSecs: (e.current_position / 1000).toFixed(0),

});

return;

});

};

onStopRecord = async () => {

const { recordSecs, uri_audio, startRecord } = this.state

if (!startRecord) return

await this.audioRecorderPlayer.stopRecorder();

const content = {

currentPositionSec: 0,

recordSecs: 0,

startRecord: false,

duration: recordSecs,

uri_audio,

startPlay: false,

playTime: 0,

}

this.setState(content)

};

Here is the code,that I post audio file to server:

const dataAudio = {

uri: this.state.uri_audio,

type: Platform.OS == 'ios' ? 'audio/m4a' : 'audio/mp4',

name: Platform.OS == 'ios' ? 'sound.m4a' : 'sound.mp4',

}

const data = new FormData()

data.append("content", dataAudio)

res = await Apis.createAudio(data)

Here is the audio' url after fetch api:
http://118.70.180.81:8055/UserAudio/74fca23d-fc54-4b5d-9213-1d220abaf22a/2019/6/1560826688hccqb0.m4a

@hyochan
Copy link
Owner

hyochan commented Sep 14, 2019

You now can pass various variables when recording from 2.3.0. Please try this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants