-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ExoPlayer] 🎵 Demo using exo player to modif speed and pitch
- Loading branch information
1 parent
b3b70c4
commit b297dec
Showing
45 changed files
with
671 additions
and
235 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
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,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<dimen name="toolbar_height">52dp</dimen> | ||
<dimen name="toolbar_height_2">104dp</dimen> | ||
|
||
<!-- Default values --> | ||
<dimen name="default_space_quart">2dp</dimen> | ||
<dimen name="default_space_half">4dp</dimen> | ||
<dimen name="default_space">8dp</dimen> | ||
<dimen name="default_space_1_5">16dp</dimen> | ||
<dimen name="default_space_2">24dp</dimen> | ||
<dimen name="default_space_3">32dp</dimen> | ||
<dimen name="default_space_4">40dp</dimen> | ||
<dimen name="default_space_5">48dp</dimen> | ||
<dimen name="default_radius">2dp</dimen> | ||
<dimen name="default_radius_2">4dp</dimen> | ||
|
||
<dimen name="text_size_xs">10sp</dimen> | ||
<dimen name="text_size_s">11sp</dimen> | ||
<dimen name="text_size_m">12sp</dimen> | ||
<dimen name="text_size_l">14sp</dimen> | ||
<dimen name="text_size_l_5">16sp</dimen> | ||
<dimen name="text_size_xl">18sp</dimen> | ||
<dimen name="text_size_xxl">22sp</dimen> | ||
<dimen name="text_size_xxxl">26sp</dimen> | ||
</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
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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-323 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_bass_01.wav
Binary file not shown.
Binary file removed
BIN
-314 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_bass_02.wav
Binary file not shown.
Binary file removed
BIN
-354 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_bass_03.wav
Binary file not shown.
Binary file removed
BIN
-320 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_bass_04.wav
Binary file not shown.
Binary file removed
BIN
-161 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_hat_01.wav
Binary file not shown.
Binary file removed
BIN
-160 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_kick_01.wav
Binary file not shown.
Binary file removed
BIN
-662 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_melody_01.wav
Binary file not shown.
Binary file removed
BIN
-654 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_melody_02.wav
Binary file not shown.
Binary file removed
BIN
-661 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_melody_03.wav
Binary file not shown.
Binary file removed
BIN
-664 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_melody_04.wav
Binary file not shown.
Binary file removed
BIN
-199 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_snare_01.wav
Binary file not shown.
Binary file removed
BIN
-495 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_a_vox_01.wav
Binary file not shown.
Binary file removed
BIN
-334 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_bass_01.wav
Binary file not shown.
Binary file removed
BIN
-331 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_bass_02.wav
Binary file not shown.
Binary file removed
BIN
-337 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_bass_03.wav
Binary file not shown.
Binary file removed
BIN
-344 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_bass_04.wav
Binary file not shown.
Binary file removed
BIN
-157 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_hat_01.wav
Binary file not shown.
Binary file removed
BIN
-102 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_kick_01.wav
Binary file not shown.
Binary file removed
BIN
-538 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_melody_01.wav
Binary file not shown.
Binary file removed
BIN
-535 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_melody_02.wav
Binary file not shown.
Binary file removed
BIN
-541 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_melody_03.wav
Binary file not shown.
Binary file removed
BIN
-537 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_melody_04.wav
Binary file not shown.
Binary file removed
BIN
-324 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_snare_01.wav
Binary file not shown.
Binary file removed
BIN
-738 KB
soundsystem/src/main/assets/wav/shape-of-you/dpm_shape_of_you_b_vox_01.wav
Binary file not shown.
63 changes: 63 additions & 0 deletions
63
soundsystem/src/main/java/com/mercandalli/android/sdk/soundsystem/Player.kt
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,63 @@ | ||
package com.mercandalli.android.sdk.soundsystem | ||
|
||
interface Player { | ||
|
||
val audioSessionId: Int | ||
|
||
val isPlaying: Boolean | ||
|
||
val duration: Long | ||
|
||
val currentPosition: Int | ||
|
||
fun load(path: String) | ||
|
||
fun play() | ||
|
||
fun pause() | ||
|
||
fun stop() | ||
|
||
fun release() | ||
|
||
fun getPitch():Float | ||
|
||
fun getSpeed():Float | ||
|
||
/** | ||
* Sets the audio volume, with 0 being silence and 1 being unity gain. | ||
* | ||
* @param volume The audio volume. | ||
*/ | ||
fun setVolume(volume: Float) | ||
|
||
/** | ||
* The factor by which playback will be sped up. | ||
*/ | ||
fun setSpeed(speed: Float) | ||
|
||
/** | ||
* The factor by which the audio pitch will be scaled. | ||
*/ | ||
fun setPitch(pitch: Float) | ||
|
||
fun seekTo(ms: Long) | ||
|
||
fun registerListener(listener: PlayerListener) | ||
|
||
fun unregisterListener(listener: PlayerListener) | ||
|
||
interface PlayerListener { | ||
|
||
fun onComplete(player: Player) | ||
|
||
fun onPrepare(player: Player) | ||
|
||
fun onError(player: Player) | ||
|
||
fun onBufferingStart(player: Player) | ||
|
||
fun onBufferingComplete(player: Player) | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
soundsystem/src/main/java/com/mercandalli/android/sdk/soundsystem/PlayerProvider.kt
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,29 @@ | ||
package com.mercandalli.android.sdk.soundsystem | ||
|
||
import android.content.Context | ||
import com.google.android.exoplayer2.DefaultRenderersFactory | ||
import com.google.android.exoplayer2.ExoPlayerFactory | ||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector | ||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory | ||
import com.google.android.exoplayer2.util.Util | ||
|
||
class PlayerProvider { | ||
companion object { | ||
|
||
@JvmStatic | ||
fun create(context: Context): Player { | ||
val renderersFactory = DefaultRenderersFactory( | ||
context, | ||
null, | ||
DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF) | ||
val simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, DefaultTrackSelector()) | ||
val dataSourceFactory = DefaultDataSourceFactory( | ||
context, | ||
Util.getUserAgent(context, "MusicPlayer")) | ||
return SimpleExoPlayerWrapper( | ||
simpleExoPlayer, | ||
dataSourceFactory) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.