mirror of
https://github.com/SimpleMobileTools/Simple-Voice-Recorder.git
synced 2025-02-25 07:57:42 +01:00
Merge pull request #63 from Aga-C/add-ogg-support
Added OPUS codec support (#38)
This commit is contained in:
commit
4543621768
@ -102,6 +102,10 @@ class SettingsActivity : SimpleActivity() {
|
||||
RadioItem(EXTENSION_MP3, getString(R.string.mp3))
|
||||
)
|
||||
|
||||
if (isQPlus()) {
|
||||
items.add(RadioItem(EXTENSION_OGG, getString(R.string.ogg)))
|
||||
}
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.extension) {
|
||||
config.extension = it as Int
|
||||
settings_extension.text = config.getExtensionText()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.simplemobiletools.voicerecorder.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaRecorder
|
||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
|
||||
@ -27,6 +28,17 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
|
||||
fun getExtensionText() = context.getString(when (extension) {
|
||||
EXTENSION_M4A -> R.string.m4a
|
||||
EXTENSION_OGG -> R.string.ogg
|
||||
else -> R.string.mp3
|
||||
})
|
||||
|
||||
fun getOutputFormat() = when (extension) {
|
||||
EXTENSION_OGG -> MediaRecorder.OutputFormat.OGG
|
||||
else -> MediaRecorder.OutputFormat.MPEG_4
|
||||
}
|
||||
|
||||
fun getAudioEncoder() = when (extension) {
|
||||
EXTENSION_OGG -> MediaRecorder.AudioEncoder.OPUS
|
||||
else -> MediaRecorder.AudioEncoder.AAC
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ const val TOGGLE_PAUSE = PATH + "TOGGLE_PAUSE"
|
||||
|
||||
const val EXTENSION_M4A = 0
|
||||
const val EXTENSION_MP3 = 1
|
||||
const val EXTENSION_OGG = 2
|
||||
|
||||
val BITRATES = arrayListOf(32000, 64000, 96000, 128000, 160000, 192000, 256000, 320000)
|
||||
const val DEFAULT_BITRATE = 128000
|
||||
|
@ -74,8 +74,8 @@ class RecorderService : Service() {
|
||||
currFilePath = "$baseFolder/${getCurrentFormattedDateTime()}.${config.getExtensionText()}"
|
||||
recorder = MediaRecorder().apply {
|
||||
setAudioSource(MediaRecorder.AudioSource.CAMCORDER)
|
||||
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
|
||||
setAudioEncoder(MediaRecorder.AudioEncoder.AAC)
|
||||
setOutputFormat(config.getOutputFormat())
|
||||
setAudioEncoder(config.getAudioEncoder())
|
||||
setAudioEncodingBitRate(config.bitrate)
|
||||
setAudioSamplingRate(44100)
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
<string name="package_name">com.simplemobiletools.voicerecorder</string>
|
||||
<string name="m4a">m4a</string>
|
||||
<string name="mp3">mp3</string>
|
||||
<string name="ogg">ogg</string>
|
||||
<string name="bitrate_value">%d kbps</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user