-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ♻️ Refactor MainActivity to implement new feature * ⚗️ Experiment with AudioRecord * 🚧 Try to make MediaRecorder work Something is wrong "mediarecorder went away with unhandled events" * ⚗️ Experiment with MediaRecorder * ⚗️ Provide a working example with SurfaceView * ⚗️ Introduce a partly-working view * ✨ Support recording a sound * 🍻 Add audio effects. Fix chronometer position * ⚡ Replace Chronometer by a CountDownTimer * 🐛 Fix the line not going to the end of the view * ♻️ Clean up code * ⚡ Clean up files not saved * 🐛 Fix destroyrecorder crashing the app * 📱 Use correctly compound view Need to update the PlayerView * ⚡ Replace constraintlayout by merge tag * 💄 Make minor graphical adjustments * ✨ Add a possibility of metadata retriever Usually this would be a viewModel * 💄 Add control buttons * 🐛 Fix the sound not being recorded properly * 🐛 Fix multiple recording and play causing crash * 🎨 Place player inside recordercontroller * 💄 Support feedback when playing * 🐛 Fix crash when destroyPlayer * 🐛 Fix validate button not being properly used * 🐛 Fix FileNotFoundException onStopRecording * 🐛 Fix UI thread blocked when converting to wav * 🐛 Fix recording line not going to the end * 💄 Prevent activity from turning screen off * 🔥 Delete files when not used * 📝 Update README.md for 1.2.0
- Loading branch information
Showing
29 changed files
with
1,269 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package fr.haran.example | ||
|
||
import android.os.Bundle | ||
import android.view.KeyEvent | ||
import android.view.WindowManager | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import fr.haran.soundwave.controller.DefaultRecorderController | ||
import java.io.File | ||
|
||
private const val TAG = "RecActivity" | ||
class RecActivity : AppCompatActivity(), DefaultRecorderController.InformationRetriever { | ||
|
||
private var recorderController: DefaultRecorderController? = null | ||
private lateinit var soundPath: String | ||
private lateinit var soundAmplitudes: List<Int> | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_rec) | ||
recorderController = applicationContext.externalCacheDir?.absolutePath?.let { it -> | ||
DefaultRecorderController(findViewById(R.id.rec_player_view), | ||
it, this | ||
) | ||
} | ||
recorderController?.setRecorderListener( | ||
start = { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }, | ||
complete = { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)}, | ||
validate = { | ||
Toast.makeText( | ||
this@RecActivity, | ||
"Sound Recorded !", | ||
Toast.LENGTH_SHORT | ||
).show()} | ||
) | ||
recorderController?.prepareRecorder() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
recorderController?.let { | ||
val wavFile = File(it.wavPath) | ||
if (wavFile.exists()) | ||
wavFile.canonicalFile.delete() | ||
it.destroyController() | ||
recorderController = null | ||
} | ||
} | ||
|
||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { | ||
if (keyCode == KeyEvent.KEYCODE_BACK) { | ||
finish() | ||
} | ||
return super.onKeyDown(keyCode, event) | ||
} | ||
|
||
override fun setPath(path: String) { | ||
soundPath = path | ||
} | ||
|
||
override fun setAmplitudes(amplitudes: List<Int>) { | ||
soundAmplitudes = amplitudes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M6,6h12v12H6z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:id="@+id/container" | ||
tools:context=".PlayActivity"> | ||
|
||
<TextView | ||
android:id="@+id/hello_world" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="PlayerView" | ||
android:textSize="25sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.233" /> | ||
|
||
<fr.haran.soundwave.ui.PlayerView | ||
android:id="@+id/player_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="200dp" | ||
app:title="Music Title" | ||
app:waveDb="true" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/hello_world" | ||
app:mainColor="@android:color/black" | ||
app:secondaryColor="@android:color/darker_gray"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".RecActivity"> | ||
|
||
<fr.haran.soundwave.ui.RecPlayerView | ||
android:id="@+id/rec_player_view" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
app:rec_color="@android:color/black" | ||
app:rec_playedColor="@android:color/darker_gray" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<resources> | ||
<string name="app_name">Example</string> | ||
<string name="playerview">PlayerView</string> | ||
<string name="recordingview">RecordingView</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.