-
Notifications
You must be signed in to change notification settings - Fork 305
Migrate MediaPlayer to ExoPlayer #5980
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
base: develop
Are you sure you want to change the base?
Changes from all commits
60fb8ba
e17a6e5
7ea6b8b
d78fbb1
d5c0b5d
c24066f
bf29e5f
11702c9
c00c7a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,15 +17,15 @@ | |
| package io.getstream.chat.android.client | ||
|
|
||
| import android.content.Context | ||
| import android.media.AudioAttributes | ||
| import android.media.MediaPlayer | ||
| import android.os.Build | ||
| import android.util.Log | ||
| import androidx.annotation.CheckResult | ||
| import androidx.lifecycle.DefaultLifecycleObserver | ||
| import androidx.lifecycle.Lifecycle | ||
| import androidx.lifecycle.LifecycleOwner | ||
| import androidx.lifecycle.ProcessLifecycleOwner | ||
| import androidx.media3.common.AudioAttributes | ||
| import androidx.media3.common.C.AUDIO_CONTENT_TYPE_MUSIC | ||
| import androidx.media3.exoplayer.ExoPlayer | ||
| import io.getstream.chat.android.client.ChatClient.Companion.MAX_COOLDOWN_TIME_SECONDS | ||
| import io.getstream.chat.android.client.api.ChatApi | ||
| import io.getstream.chat.android.client.api.ChatClientConfig | ||
|
|
@@ -69,7 +69,7 @@ import io.getstream.chat.android.client.api2.model.dto.DownstreamUserDto | |
| import io.getstream.chat.android.client.attachment.AttachmentsSender | ||
| import io.getstream.chat.android.client.audio.AudioPlayer | ||
| import io.getstream.chat.android.client.audio.NativeMediaPlayerImpl | ||
| import io.getstream.chat.android.client.audio.StreamMediaPlayer | ||
| import io.getstream.chat.android.client.audio.StreamAudioPlayer | ||
| import io.getstream.chat.android.client.channel.ChannelClient | ||
| import io.getstream.chat.android.client.channel.state.ChannelStateLogicProvider | ||
| import io.getstream.chat.android.client.clientstate.DisconnectCause | ||
|
|
@@ -984,7 +984,7 @@ internal constructor( | |
| * @param file The image file that needs to be uploaded. | ||
| * @param callback The callback to track progress. | ||
| * | ||
| * @return Executable async [Call] which completes with [Result] containing an instance of [UploadedImage] | ||
| * @return Executable async [Call] which completes with [Result] containing an instance of [UploadedFile] | ||
| * if the image was successfully uploaded. | ||
| * | ||
| * @see FileUploader | ||
|
|
@@ -1108,7 +1108,6 @@ internal constructor( | |
| * @see FileUploader | ||
| */ | ||
| @CheckResult | ||
| @JvmOverloads | ||
| public fun deleteImage( | ||
| url: String, | ||
| ): Call<Unit> = api.deleteImage(url) | ||
|
|
@@ -4602,8 +4601,8 @@ internal constructor( | |
| } | ||
|
|
||
| /** | ||
| * Debug requests using [ApiRequestsAnalyser]. Use this to debug your requests. This shouldn't be enabled in | ||
| * release builds as it uses a memory cache. | ||
| * Debug requests using [io.getstream.chat.android.client.plugins.requests.ApiRequestsAnalyser]. Use this to | ||
| * debug your requests. This shouldn't be enabled in release builds as it uses a memory cache. | ||
| */ | ||
| public fun debugRequests(shouldDebug: Boolean): Builder = apply { | ||
| this.debugRequests = shouldDebug | ||
|
|
@@ -4719,17 +4718,18 @@ internal constructor( | |
|
|
||
| val appSettingsManager = AppSettingManager(module.api()) | ||
|
|
||
| val audioPlayer: AudioPlayer = StreamMediaPlayer( | ||
| mediaPlayer = NativeMediaPlayerImpl { | ||
| MediaPlayer().apply { | ||
| AudioAttributes.Builder() | ||
| .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) | ||
| .build() | ||
| .let(this::setAudioAttributes) | ||
| } | ||
| val audioPlayer: AudioPlayer = StreamAudioPlayer( | ||
| mediaPlayer = NativeMediaPlayerImpl(appContext) { | ||
| ExoPlayer.Builder(appContext) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit worried about the size bump of the SDK. Some companies pay attention to that. Can we do it in a way to check if the dependency exists at runtime and decide whether to use ExoPlayer based on that? I'm thinking, maybe we can add ExoPlayer as private boolean isExoPlayerAvailable() {
try {
Class.forName("androidx.media3.exoplayer.ExoPlayer");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and if it does not? Fallback to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it adds unnecessary complexity to already complex chat. I think we need to live with the 1.9MBs. @VelikovPetar why has offline increased for 2MB? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Another (a bit more complex) solution would be to move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The correct way to avoid the 2MB increase is I think to have the contract live in chat and default However this goes against our goal of reducing integration complexity and dependencies. I think including exo player is not an optional dependency when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey @VelikovPetar - Maybe try this Instead of includign the entire exoplayer dep We can include its modules that we need as of now media3-exoplayer-core -> this one is always required Apart from this, we only need the type of streaming we are supporting : The other modules are : media3-exoplayer-dash -> For DASH (MPEG-DASH) streaming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We checked this, but unfortunately the legacy |
||
| .setAudioAttributes( | ||
| AudioAttributes.Builder() | ||
| .setContentType(AUDIO_CONTENT_TYPE_MUSIC) | ||
| .build(), | ||
| true, | ||
| ) | ||
| .build() | ||
| }, | ||
| userScope = userScope, | ||
| isMarshmallowOrHigher = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M, | ||
| ) | ||
|
|
||
| return ChatClient( | ||
|
|
@@ -4878,7 +4878,6 @@ internal constructor( | |
| */ | ||
| @Throws(IllegalStateException::class) | ||
| @JvmStatic | ||
| @JvmOverloads | ||
| public fun handlePushMessage(pushMessage: PushMessage) { | ||
| ensureClientInitialized().run { | ||
| val type = pushMessage.type.orEmpty() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.