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

The Wave is flat #20

Closed
PBasil2020 opened this issue May 8, 2021 · 12 comments · Fixed by #22
Closed

The Wave is flat #20

PBasil2020 opened this issue May 8, 2021 · 12 comments · Fixed by #22

Comments

@PBasil2020
Copy link

The wave is not like the one you have shown. It is coming of a uniform height

@PBasil2020
Copy link
Author

Requesting help. The seekbar is working but wave is flat (all columns same height) and alignment to top, bottom and center is same .

Need urgent guidance . Please help

@lincollincol
Copy link
Contributor

@PBasil2020 Hello, send me your audio file to xlincollincolx@gmail.com and I'll try to reproduce this bug

@PBasil2020
Copy link
Author

@PBasil2020 Hello, send me your audio file to xlincollincolx@gmail.com and I'll try to reproduce this bug

Thank you for responding. I am using multiple audio files and everywhere same. The one with maximum modulation is attached.

I am using Android studio 4.2 and application is in Java.

I am observing this

  1. Wave is flat , like a solid rectangle.
  2. Also, No change on changing the gravity to top or center or bottom.

Regards
Preeti

Queen - Bohemian Rhapsody.zip

lincollincol added a commit to lincollincol/waveformSeekBar that referenced this issue May 16, 2021
@lincollincol
Copy link
Contributor

@PBasil2020 Check WaveformSeekbar and Amplituda versions:

implementation  'com.github.massoudss:waveformSeekBar:2.4.0'
implementation 'com.github.lincollincol:Amplituda:1.7'

You should also increase WaveformSeekbar version to 2.4.0 if you want to use new Amplituda version with this fix

I'll attach a screenshot with the waveform for your audio file here.
wave

@PBasil2020
Copy link
Author

PBasil2020 commented May 17, 2021 via email

@lincollincol
Copy link
Contributor

lincollincol commented May 17, 2021

@PBasil2020 Try to use this step by step instruction:
Step 1:
Add dependency
Project Gradle file =>

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Module Gradle file =>

dependencies {
    implementation  'com.github.massoudss:waveformSeekBar:2.4.0'
    implementation 'com.github.lincollincol:Amplituda:1.7' // or newer version
}

Step 2:
Add read/write permissions to your manifest.xml file and grant it

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Step 3:
Add WaveformSeekbar view to your layout markup. Example of layout markup:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.masoudss.lib.WaveformSeekBar
        app:wave_progress="33"
        app:wave_max_progress="100"
        app:wave_width="5dp"
        app:wave_gap="2dp"
        app:wave_min_height="5dp"
        app:wave_corner_radius="2dp"
        app:wave_background_color="#ffaacc"
        app:wave_progress_color="#9000ff00"
        app:wave_gravity="center"
        android:id="@+id/waveformSeekBar"
        android:layout_width="300dp"
        android:layout_height="50dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Step 4:
Set samples from code inside your activity or fragment:

val waveform = findViewById<WaveformSeekBar>(R.id.waveformSeekBar)
waveform.setSampleFrom(path) // Example path => "/storage/emulated/0/Music/queen.mp3"

Сonclusion

  • If you get runtime error like libavutil.so not found - check your project gradle file and increase "com.android.tools.build:gradle" version to 4.1.1 or higher. Example:
dependencies {
    classpath "com.android.tools.build:gradle:4.1.1"
    . . .
}

You can also send me runtime logs

@PBasil2020
Copy link
Author

PBasil2020 commented May 18, 2021 via email

@lincollincol
Copy link
Contributor

@PBasil2020 Please use the correct path to the file. The file must exist and have an extension according to the audio files: mp3, wav etc. Also, check that you have granted read and write permissions.
See log message from your reply:
E/AMPLITUDA: Wrong file! Please check path and try again!

@PBasil2020
Copy link
Author

PBasil2020 commented May 18, 2021 via email

@lincollincol
Copy link
Contributor

@PBasil2020 Yes, you should store it on your device: internal or external (sd-card) storage. I think it would be nice to add support for raw files, but that will be a little bit later.

@massoudss
Copy link
Owner

@PBasil2020 Please convert your raw resource to a temp file and use the returning file:

fun getRawResourceAsFile(): File {
    val inputStream = resources.openRawResource(R.raw.your_resource_name)
    val file = File(cacheDir, "your_file_name.mp3")
    try {
        FileOutputStream(file).use { output ->
            val buffer = ByteArray(4 * 1024)
            var read: Int
            while (inputStream.read(buffer).also { read = it } != -1) {
                output.write(buffer, 0, read)
            }
            output.flush()
        }
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        inputStream.close()
    }
    return file
}

@PBasil2020
Copy link
Author

PBasil2020 commented May 19, 2021 via email

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.

3 participants