From 5eb5a88f312ee2d836e19af42a150fb87a2b0ad5 Mon Sep 17 00:00:00 2001 From: alex11111115 Date: Sat, 3 Aug 2024 17:10:10 +0300 Subject: [PATCH] Initial commit --- .androidide/editor/openedFiles.json | 61 +++++++++++++--- README.md | 69 ++++++++++--------- WavePlayerView/build.gradle | 6 ++ .../sound/wave/kilobyte/WavePlayerView.java | 2 + app/build.gradle | 5 ++ .../sound/wave/kilobyte/MainActivity.java | 16 +++-- 6 files changed, 113 insertions(+), 46 deletions(-) diff --git a/.androidide/editor/openedFiles.json b/.androidide/editor/openedFiles.json index 1a62a72..e6e05f2 100644 --- a/.androidide/editor/openedFiles.json +++ b/.androidide/editor/openedFiles.json @@ -1,20 +1,65 @@ { "allFiles": [ { - "file": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/README.md", + "file": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/WavePlayerView/src/main/java/sound/wave/kilobyte/WavePlayerView.java", "selection": { "end": { - "column": 65, - "index": 1806, - "line": 19 + "column": 31, + "index": 11483, + "line": 328 }, "start": { - "column": 65, - "index": 1806, - "line": 19 + "column": 31, + "index": 11483, + "line": 328 + } + } + }, + { + "file": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/app/src/main/java/sound/wave/kilobyte/MainActivity.java", + "selection": { + "end": { + "column": 38, + "index": 9093, + "line": 223 + }, + "start": { + "column": 38, + "index": 9093, + "line": 223 + } + } + }, + { + "file": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/app/build.gradle", + "selection": { + "end": { + "column": 75, + "index": 357, + "line": 17 + }, + "start": { + "column": 75, + "index": 357, + "line": 17 + } + } + }, + { + "file": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/WavePlayerView/build.gradle", + "selection": { + "end": { + "column": 74, + "index": 1653, + "line": 64 + }, + "start": { + "column": 74, + "index": 1653, + "line": 64 } } } ], - "selectedFile": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/README.md" + "selectedFile": "/storage/emulated/0/AndroidIDEProjects/WavePlayerView/WavePlayerView/src/main/java/sound/wave/kilobyte/WavePlayerView.java" } \ No newline at end of file diff --git a/README.md b/README.md index d1d5177..3f43372 100644 --- a/README.md +++ b/README.md @@ -6,39 +6,44 @@ # WavePlayerView ![http://developer.android.com/index.html](https://github.com/alex11111115/WavePlayerView/assets/96258291/3fc4547a-a929-43c3-8cf0-ee16b066fb7e) - - WavePlayerView Logo - - +

+ WavePlayerView Logo + +

-WavePlayerView is an advanced library for analyzing real-time audio and displaying sound waves in an engaging and interactive way. +

WavePlayerView: Analyze real-time audio and display sound waves in an interactive and engaging way 🎵

-## Features +## ✨ Features -- **Real-time audio analysis**: View sound waves while recording or playing an audio file. -- **Customize Display**: Easily adjust wave colors, line widths, and wave speeds. -- **Easy-to-use Programming Interface**: Simple and intuitive programming interface for seamless integration. -- **Wide Compatibility**: Supports Android API level 21 and above. [![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21) -- **Advanced Control**: Playback speed control, pause/resume functions, and audio progress monitoring. -- **Audio Recording**: Ability to record audio and display real-time waveforms. -- **Volume Control**: Adjust the volume for the left and right channels. -- **Repeat Playback**: Ability to set repeated playback of the audio file. +- 🔊 **Real-time audio analysis**: View sound waves while recording or playing an audio file. +- 🎨 **Customize Display**: Easily adjust wave colors, line widths, and wave speeds. +- 🚀 **Easy-to-use Programming Interface**: Simple and intuitive programming interface for seamless integration. +- 📱 **Wide Compatibility**: Supports Android API level 21 and above. [![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21) +- 🎛️ **Advanced Control**: Playback speed control, pause/resume functions, and audio progress monitoring. +- 🎙️ **Audio Recording**: Ability to record audio and display real-time waveforms. +- 🔈 **Volume Control**: Adjust the volume for the left and right channels. +- 🔁 **Repeat Playback**: Ability to set repeated playback of the audio file. -## Screenshot -![Screenshot_٢٠٢٤٠٦٠٥-١٠٢٤٥٠_Sound Wave Visualization](https://github.com/alex11111115/WavePlayerView/assets/96258291/5b185180-3fcf-4078-ba9c-75c9aa9c776f) -![Screenshot_٢٠٢٤٠٦٠٥-١٠٢٤١٨_Sound Wave Visualization](https://github.com/alex11111115/WavePlayerView/assets/96258291/b356224d-e6d7-4fd0-8a4b-16d778f859fc) -![Screenshot_٢٠٢٤٠٦٠٥-١٤٥١٥٨_Wave Player](https://github.com/alex11111115/WavePlayerView/assets/96258291/beaf3a5b-49b9-4487-b3f9-94cbeb1cb0d3) -![Screenshot_٢٠٢٤٠٦٠٥-١٤٥٢٠٢_Wave Player](https://github.com/alex11111115/WavePlayerView/assets/96258291/3dd56ed2-d9d2-4baf-a337-b64df2c9e309) -![Screenshot_٢٠٢٤٠٦٠٥-١٤٥٢٠٥_Wave Player](https://github.com/alex11111115/WavePlayerView/assets/96258291/16ad97cd-128e-4483-93d7-fd80ab55246a) +## 🤔 Why use WavePlayerView? -![Screenshot_٢٠٢٤٠٦٠٧-٠٩٢٣٠٢_WavePlayerView](https://github.com/alex11111115/WavePlayerView/assets/96258291/a6b7698b-751b-47ce-961d-33314c1c0795) +- 🚀 **High Performance**: Designed for high efficiency with minimal impact on your app's performance. +- 🔓 **Open Source**: Full access to the source code for customization and optimization. +- 👥 **Community Support**: Supported by a dedicated community, with opportunities for contributions and improvements. +- 🎠 **Highly Smooth**: Utilizes the latest and most powerful algorithms to deliver an impressive and smooth result -## Why Use WavePlayerView? +## 📸 Screenshots + +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٢٥٢_WavePlayerView](https://github.com/user-attachments/assets/d9b204e2-01a5-4bc4-bee0-66d410f23378) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٣٠٥_WavePlayerView](https://github.com/user-attachments/assets/f0b844a8-9358-440c-8840-d566b182fc1e) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٣١٠_WavePlayerView](https://github.com/user-attachments/assets/90a1e819-963c-4b2a-a302-ba45c3a30969) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٣١٨_WavePlayerView](https://github.com/user-attachments/assets/53c96220-8cd5-4240-92af-1d1459e57904) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٦٤٦_WavePlayerView](https://github.com/user-attachments/assets/b2109d91-62d2-4c53-88b4-7a81e4b944a9) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٦٥٠_WavePlayerView](https://github.com/user-attachments/assets/cae5b3d2-d96b-485a-946c-15129fe71b15) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٧٠١_WavePlayerView](https://github.com/user-attachments/assets/db77a4b7-115e-4a32-8624-d2a651a00dd2) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٧١٢_WavePlayerView](https://github.com/user-attachments/assets/093aa667-38cf-4218-a2f5-0c408ea943d0) +![Screenshot_٢٠٢٤٠٨٠٣-١٤٠٧١٩_WavePlayerView](https://github.com/user-attachments/assets/681192a2-a8fd-49e3-9a22-75218fc9e5bf) -- **High Performance**: Engineered for high efficiency with minimal impact on your application's performance. -- **Open Source**: Full access to source code for customization and enhancement. -- **Community Support**: Supported by a dedicated community, with opportunities for contributions and improvements. ## How to Use the Library? ![GitHub top language](https://img.shields.io/github/languages/top/alex11111115/WavePlayerView?style=flat&color=red) @@ -242,13 +247,14 @@ waveView.setLooping(true); if (waveView != null) { waveView.release(); } +``` -> To Wave1 Alpha +> To set wave1 alpha ```java waveView.setWave1Alpha(alpha1); ``` -> To Wave2 Alpha +> To set wave2 alpha ```java waveView.setWave2Alpha(alpha2); ``` @@ -258,15 +264,14 @@ waveView.setWave2Alpha(alpha2); > Add the following permissions to your `AndroidManifest.xml`: ```xml - ``` -## Important notes +## 📝 Important Notes -- Be sure to request voice recording permissions at runtime for devices running Android 6.0 and above. +- Be sure to ask for audio recording permissions at runtime for devices running Android 6.0 and above. - The appearance of the waves can be customized through various properties available in XML or programmatically. -- Use `setPlaybackSpeed()' to change the playback speed. Allowable values range from 0.2 to 6.0. +- Use `setPlaybackSpeed()` to change the playback speed. Allowable values range from 0.2 to 6.0. - You can control the volume with `setVolume()` where the values range from 0.0 (mute) to 1.0 (loudest). - Use `setLooping()` to set whether the sound will automatically repeat after it ends. @@ -315,4 +320,4 @@ WavePlayerView is licensed under the [Apache License 2.0](http://www.apache.org/

Build Status

Build Status - \ No newline at end of file + diff --git a/WavePlayerView/build.gradle b/WavePlayerView/build.gradle index e538ed7..24087c8 100644 --- a/WavePlayerView/build.gradle +++ b/WavePlayerView/build.gradle @@ -13,6 +13,8 @@ android { versionCode 2 versionName "1.12" namespace "sound.wave.kilobyte" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -57,6 +59,10 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } publishing { diff --git a/WavePlayerView/src/main/java/sound/wave/kilobyte/WavePlayerView.java b/WavePlayerView/src/main/java/sound/wave/kilobyte/WavePlayerView.java index db6ab1c..6e3d1f6 100644 --- a/WavePlayerView/src/main/java/sound/wave/kilobyte/WavePlayerView.java +++ b/WavePlayerView/src/main/java/sound/wave/kilobyte/WavePlayerView.java @@ -312,6 +312,7 @@ public void pauseAudioWithWave() { public void resumeAudioWithWave() { if (mediaPlayer != null && isPaused) { mediaPlayer.seekTo(pausedPosition); + setupMediaPlayer(); setPlaybackSpeed(playbackSpeed); mediaPlayer.start(); isPaused = false; @@ -325,6 +326,7 @@ public void resumeAudioWithWave() { public void seekToPosition(int pos) { if (mediaPlayer != null && isPaused) { mediaPlayer.seekTo(pos); + setupMediaPlayer(); setPlaybackSpeed(playbackSpeed); mediaPlayer.start(); isPaused = false; diff --git a/app/build.gradle b/app/build.gradle index 6c36282..4a69ebf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,6 +15,8 @@ android { versionCode 2 versionName "1.12" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { useSupportLibrary true } @@ -46,4 +48,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } \ No newline at end of file diff --git a/app/src/main/java/sound/wave/kilobyte/MainActivity.java b/app/src/main/java/sound/wave/kilobyte/MainActivity.java index 3b97b18..8c3c800 100644 --- a/app/src/main/java/sound/wave/kilobyte/MainActivity.java +++ b/app/src/main/java/sound/wave/kilobyte/MainActivity.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Map; public class MainActivity extends AppCompatActivity { @@ -95,12 +96,12 @@ private void setupLaunchers() { permissionLauncher = registerForActivityResult( new ActivityResultContracts.RequestMultiplePermissions(), result -> { - boolean allGranted = result.entrySet().stream() - .allMatch(entry -> entry.getValue()); - if (allGranted) { - initializeLogic(); - } else { - Toast.makeText(this, "الصلاحيات مطلوبة لتشغيل التطبيق بشكل صحيح", Toast.LENGTH_LONG).show(); + boolean allGranted = true; + for (Map.Entry entry : result.entrySet()) { + if (!entry.getValue()) { + allGranted = false; + break; + } } } ); @@ -219,6 +220,8 @@ public void onStartTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) { waveView.seekToPosition((int) seekPosition); waveView.resumeAudioWithWave(); + setupAudioPlayer(); + updatePlaybackSpeed(); } }); @@ -327,6 +330,7 @@ private void stopAudio() { private void resumeAudio() { waveView.resumeAudioWithWave(); + setupAudioPlayer(); updatePlaybackSpeed(); }