Xiaomi Redmi Note having issues when casting?

After digging into the Stacktrace, this section:
java.lang.IllegalArgumentException: The given region must intersect with the Bitmap's dimensions.

gives away some information: the error doesn’t look to be related with casting itself, since the issue looks to be at the System UI level.

I am not an expert on Xiaomi, but few Forums suggest that the MIUI is sometimes problematic and even a suggestion about disabling MIUI optimisation on the developer tools is very popular (I tried disabling this but it had no effect on this issue ).

Disabling the MediaSession within the CastOptionsProvider seems to solve this issue.

In order to do this for the Bitmovin SDK, the following steps can be done:

  1. Create a new class CustomCastOptionsProvider:
package com.bitmovin.player.samples.casting.basic;

import android.content.Context;
import com.bitmovin.player.casting.BitmovinCastManager;
import com.google.android.gms.cast.LaunchOptions;
import com.google.android.gms.cast.framework.CastOptions;
import com.google.android.gms.cast.framework.OptionsProvider;
import com.google.android.gms.cast.framework.SessionProvider;
import com.google.android.gms.cast.framework.media.CastMediaOptions;

import java.util.List;

public class CustomCastOptionsProvider implements OptionsProvider {
    @Override
    public CastOptions getCastOptions(Context context) {
        Class expandedControllerActivity = BitmovinCastManager.getInstance().getCastControllerActivityClass();
        String expandedControllerActivityName = expandedControllerActivity != null ?
            expandedControllerActivity.getName() : null;

        LaunchOptions launchOptions = new LaunchOptions.Builder()
            .setRelaunchIfRunning(true)
            .build();

        return new CastOptions.Builder()
            .setReceiverApplicationId(BitmovinCastManager.getInstance().getApplicationId())
            .setCastMediaOptions(new CastMediaOptions.Builder().setMediaSessionEnabled(false).build())
            .setLaunchOptions(launchOptions)
            .build();
    }

    @Override
    public List<SessionProvider> getAdditionalSessionProviders(Context appContext) {
        return null;
    }
}
  1. Modify the AndroidManifest.xml to include the CustomCastOptionsProvider:
 <meta-data
            android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
            android:value="com.bitmovin.player.samples.casting.basic.CustomCastOptionsProvider" />
1 Like