Added OPUS codec support (#38)
This commit is contained in:
parent
27c1202773
commit
165e06b89c
|
@ -10,8 +10,7 @@ import com.simplemobiletools.commons.helpers.isQPlus
|
|||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.helpers.EXTENSION_M4A
|
||||
import com.simplemobiletools.voicerecorder.helpers.EXTENSION_MP3
|
||||
import com.simplemobiletools.voicerecorder.helpers.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
|
||||
|
@ -101,6 +100,10 @@ class SettingsActivity : SimpleActivity() {
|
|||
RadioItem(EXTENSION_M4A, getString(R.string.m4a)),
|
||||
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
|
||||
|
||||
|
@ -23,6 +24,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
|
||||
|
||||
const val RECORDING_RUNNING = 0
|
||||
const val RECORDING_STOPPED = 1
|
||||
|
|
|
@ -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(128000)
|
||||
setAudioSamplingRate(44100)
|
||||
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
<string name="package_name">com.simplemobiletools.voicerecorder</string>
|
||||
<string name="m4a">m4a</string>
|
||||
<string name="mp3">mp3</string>
|
||||
<string name="ogg">ogg</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue