Skip to content

Commit b3e1f64

Browse files
authored
Merge pull request #68 from CodandoTV/fix/web-view-error
Resolvendo o erro do YouTube
2 parents 08562f5 + 10d61a4 commit b3e1f64

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

core-shared-ui/src/androidMain/kotlin/com/codandotv/streamplayerapp/core_shared_ui/widget/YoutubePlayerComponent.android.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ actual fun YoutubePlayerComponentPlatform(videoId: String, modifier: Modifier) {
4242
AndroidView(
4343
modifier = modifier,
4444
factory = { webView },
45-
update = { it.loadDataWithBaseURL(null, embedHTML, "text/html", "UTF-8", null) },
45+
update = { it.loadDataWithBaseURL(CODANDOTV_DOMAIN, embedHTML, "text/html", "UTF-8", null) },
4646
onReset = { it.destroy() }
4747
)
4848
}

core-shared-ui/src/commonMain/kotlin/com/codandotv/streamplayerapp/core_shared_ui/widget/YoutubePlayerComponentPlatform.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ expect fun YoutubePlayerComponentPlatform(videoId: String, modifier: Modifier =
1010

1111

1212
internal fun String.videoIdToEmbedHTML(): String {
13-
val iframeProperties = "width=\"100%\" height=\"100%\""
14-
return "<iframe $iframeProperties" +
15-
"src=\"https://www.youtube.com/embed/$this?playsinline=1\" " +
16-
"frameborder=\"0\" allowfullscreen></iframe>"
13+
return """
14+
<iframe width="100%" height="100%"
15+
src="https://www.youtube.com/embed/$this?playsinline=1"
16+
frameborder="0" allowfullscreen referrerpolicy="strict-origin-when-cross-origin"/>
17+
""".trimIndent()
1718
}
1819

20+
internal const val CODANDOTV_DOMAIN = "https://www.youtube.com/@CodandoTV"

core-shared-ui/src/iosMain/kotlin/com/codandotv/streamplayerapp/core_shared_ui/widget/YoutubePlayerComponentPlatform.ios.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable
66
import androidx.compose.runtime.remember
77
import androidx.compose.ui.Modifier
88
import androidx.compose.ui.viewinterop.UIKitView
9+
import platform.Foundation.NSURL
910
import platform.WebKit.WKWebView
1011
import platform.WebKit.WKWebViewConfiguration
1112
import platform.WebKit.WKWebsiteDataStore
@@ -23,7 +24,7 @@ actual fun YoutubePlayerComponentPlatform(videoId: String, modifier: Modifier){
2324
configuration.limitsNavigationsToAppBoundDomains = false
2425
loadHTMLString(
2526
string = embedHTML,
26-
baseURL = null
27+
baseURL = NSURL(string = CODANDOTV_DOMAIN),
2728
)
2829
}
2930
}

0 commit comments

Comments
 (0)