Java Question [solved] Is it possible to get Values from the Manifest in a Library?

DonManfred

Expert
Licensed User
Longtime User
Initialize the Cast Context
The framework has a global singleton object, the CastContext, which coordinates all the framework's interactions.

Your app must implement the OptionsProvider interface to supply options needed to initialize the CastContext singleton. OptionsProvider provides an instance of CastOptions which contains options that affect the behavior of the framework. The most important of these is the receiver application ID, which is used to filter discovery results and to launch the receiver app when a cast session is started.

B4X:
public class CastOptionsProvider implements OptionsProvider {
    @Override
    public CastOptions getCastOptions(Context context) {
        CastOptions castOptions = new CastOptions.Builder()
            .setReceiverApplicationId(context.getString(R.string.app_id))
            .build();
        return castOptions;
    }
    @Override
    public List<SessionProvider> getAdditionalSessionProviders(Context context) {
        return null;
    }
}
In this case the CastOptionsProvider is getting the app_id from a Value in R file.

I don´t want to use Extra Resources and i am trying to get the Value which is added to the Manifest with CreateResource.

How would i reference(get) such a Value from the Manifest to use it inside the CastOptionsProvider? Means what is the code needed?

Any help/tips appreciated ;-)
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Need to learn how to add a video to stream now :D
B4X:
Sub Casty_onConnected()
    Log($"Casty_onConnected()"$)
    Dim mb As MediaDataBuilder
    mb.Initialize("","http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4").setAutoPlay(True).setContentType("videos(mp4").setMediaType(1).setStreamType(1).setTitle("DonManfred presents").setSubtitle("B4A Casting Video").addPhotoUrl("https://peach.blender.org/wp-content/uploads/bbb-splash.png?x11217")

    cast.loadMediaAndPlayInBackground(mb.build)
End Sub

chromecast_097.png




** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
onCastStateChanged(3)
Casty_onCastStateChanged(Connecting to Castdevice)
Casty_onSessionResuming(com.google.android.gms.cast.framework.CastSession@b152525, 81ebe244-d143-4855-b8a0-cc95cd97858a)
Session: ID 81ebe244-d143-4855-b8a0-cc95cd97858a com.google.android.gms.cast.CATEGORY_CAST/4F8B3483///ALLOW_IPV6
onCastStateChanged(4)
Casty_onCastStateChanged(Connected)
Casty_onSessionResumed(com.google.android.gms.cast.framework.CastSession@b152525, false)
Session: ID 81ebe244-d143-4855-b8a0-cc95cd97858a com.google.android.gms.cast.CATEGORY_CAST/4F8B3483///ALLOW_IPV6
Casty_onConnected()
Casty_onCastSessionUpdated()
onCastStateChanged(2)
Casty_onCastStateChanged(Not Connected)
Casty_onSessionEnding(com.google.android.gms.cast.framework.CastSession@b152525)
Session: ID null com.google.android.gms.cast.CATEGORY_CAST/4F8B3483///ALLOW_IPV6
Casty_onSessionEnded()
Session: ID null com.google.android.gms.cast.CATEGORY_CAST/4F8B3483///ALLOW_IPV6
Casty_onDisConnected()
onCastStateChanged(3)
Casty_onCastStateChanged(Connecting to Castdevice)
Casty_onSessionStarting(com.google.android.gms.cast.framework.CastSession@9ca7121)
Session: ID null com.google.android.gms.cast.CATEGORY_CAST/4F8B3483///ALLOW_IPV6
onCastStateChanged(4)
Casty_onCastStateChanged(Connected)
Casty_onSessionStarted(com.google.android.gms.cast.framework.CastSession@9ca7121, f0bdf4ae-417b-4ff0-b086-73d407f4dc61)
Session: ID f0bdf4ae-417b-4ff0-b086-73d407f4dc61 com.google.android.gms.cast.CATEGORY_CAST/4F8B3483///ALLOW_IPV6
Casty_onConnected()
Casty_onCastSessionUpdated()
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:00:00
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:34
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:34
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:34
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:34
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:33
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:32
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:31
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:30
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:29
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:28
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:27
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:26
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:25
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:24
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:23
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:22
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:21
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:20
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:19
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:18
f0bdf4ae-417b-4ff0-b086-73d407f4dc61: Time left: 0:10:17
 
Last edited:
Top