List icon 目录

从 7.33.2 到 7.34

屏幕投射

在 JxBrowser 7.34 中,如果您想从代码中启动屏幕投射功能,您需要在 ScreenCastOptions.newBuilder(Screen) 设置屏幕:

7.33.2 及更早版本:

Java
Kotlin
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:

Java
Kotlin
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)

支持媒体源

在 JxBrowser 7.34 中, MediaReceiver.supports(CastMode) 方法已被移除。相反,您应该使用 MediaReceiver.supports(MediaSource) 方法:

7.33.2 及更早版本:

要检查接收器是否支持投射任何浏览器的内容:

Java
Kotlin
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(CastMode.BROWSER)) {
    // 逻辑
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(CastMode.BROWSER)) {
    // 逻辑
}

要检查接收器是否支持投射任何屏幕内容:

Java
Kotlin
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(CastMode.SCREEN)) {
    // 逻辑
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(CastMode.SCREEN)) {
    // 逻辑
}

要检查接收器是否支持演示:

Java
Kotlin
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(CastMode.PRESENTATION)) {
    // 逻辑
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(CastMode.PRESENTATION)) {
    // 逻辑
}

7.34:

要检查接收器是否支持投射任何浏览器的内容:

Java
Kotlin
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(MediaSource.browser())) {
    // 逻辑
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(MediaSource.browser())) {
    // 逻辑
}

要检查接收器是否支持投射任何屏幕内容:

Java
Kotlin
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
if (receiver.supports(MediaSource.screen())) {
    // 逻辑
}
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
if (receiver.supports(MediaSource.screen())) {
    // 逻辑
}

要检查接收器是否支持将特定的 PresentationRequest 作为媒体源:

Java
Kotlin
MediaReceiver receiver = mediaReceivers.await(it -> it.name().contains("Samsung"));
browser.defaultPresentationRequest().ifPresent(presentationRequest -> {
    if (receiver.supports(presentationRequest)) {
        // 逻辑
    }
});
val receiver = mediaReceivers.await { it.name().contains("Samsung") }
browser.defaultPresentationRequest().ifPresent {
    if (receiver.supports(it)) {
        // 逻辑
    }
}