From 7.33.2 to 7.34
Screen casting
In JxBrowser 7.34, if you want to start screen casting from code, you will need to set the screen in
the ScreenCastOptions.newBuilder(Screen)
:
7.33.2 and earlier:
Screen screen = profile.mediaCasting().screens().defaultScreen();
ScreenCastOptions options = ScreenCastOptions.newBuilder()
.screen(screen)
.withAudio()
.build();
CompletableFuture<CastSession> future = browser.castScreen(receiver, options);
val screen = profile.mediaCasting().screens().defaultScreen()
val options = ScreenCastOptions.newBuilder()
.screen(screen)
.withAudio()
.build()
val future: CompletableFuture<CastSession> = browser.castScreen(receiver, options)
7.34:
Screen screen = profile.mediaCasting().screens().defaultScreen();
ScreenCastOptions options = ScreenCastOptions.newBuilder(screen)
.withAudio()
.build();
CompletableFuture<CastSession> future = browser.castScreen(receiver, options);
val screen = profile.mediaCasting().screens().defaultScreen()
val options = ScreenCastOptions.newBuilder(screen)
.withAudio()
.build()
val future: CompletableFuture<CastSession> = browser.castScreen(receiver, options)
Supporting media sources
In JxBrowser 7.34, the MediaReceiver.supports(CastMode)
method has been removed. Instead, you should use
MediaReceiver.supports(MediaSource)
:
7.33.2 and earlier:
To check if a receiver supports casting any browser’s content:
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(CastMode.BROWSER)) {
// Logic
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(CastMode.BROWSER)) {
// Logic
}
To check if a receiver supports casting any screen’s content:
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(CastMode.SCREEN)) {
// Logic
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(CastMode.SCREEN)) {
// Logic
}
To check if a receiver supports presentation:
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(CastMode.PRESENTATION)) {
// Logic
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(CastMode.PRESENTATION)) {
// Logic
}
7.34:
To check if a receiver supports casting any browser’s content:
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(MediaSource.browser())) {
// Logic
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(MediaSource.browser())) {
// Logic
}
To check if a receiver supports casting any screen’s content:
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(MediaSource.screen())) {
// Logic
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(MediaSource.screen())) {
// Logic
}
To check if a receiver supports a specific PresentationRequest
as the media source:
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
browser.defaultPresentationRequest().ifPresent(presentationRequest -> {
if (receiver.supports(presentationRequest)) {
// Logic
}
});
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
browser.defaultPresentationRequest().ifPresent {
if (receiver.supports(it)) {
// Logic
}
}