Skip to content

Commit d1ca474

Browse files
fix: Preserve fullscreen mode for embedded content in WebView (#818)
- Updated loadVideo method in WebViewVideoFragment to differentiate between video and non-video embedded content based on the fullscreen class. - Video Embed Content: Wrapped in a videoWrapper to maintain a 16:9 aspect ratio. - Non-Video Embed Content: Displayed in fullscreen without additional wrapping.
1 parent 57b52f7 commit d1ca474

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

course/src/main/java/in/testpress/course/fragments/WebViewVideoFragment.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import android.os.Bundle
1717
import android.view.LayoutInflater
1818
import android.view.View
1919
import android.view.ViewGroup
20+
import android.webkit.CookieManager
2021
import android.webkit.WebView
2122
import android.widget.ProgressBar
2223
import androidx.lifecycle.Observer
@@ -82,11 +83,17 @@ open class WebViewVideoFragment : BaseVideoWidgetFragment() {
8283
webView.scrollBarStyle = WebView.SCROLLBARS_OUTSIDE_OVERLAY
8384
webView.setOnLongClickListener { true }
8485
webView.isLongClickable = false
86+
// Enable third-party cookies for embedded code content
87+
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true)
8588
}
8689

8790
open fun loadVideo(content: DomainContent) {
88-
val html = "<div style='margin-top: 15px padding-left: 20px padding-right: 20px'" +
89-
"class='videoWrapper'>" + video?.embedCode + "</div>"
91+
val html = if (video?.embedCode?.contains("class=\"fullscreenContent\"") == true) {
92+
video?.embedCode
93+
} else {
94+
"<div style='margin-top: 15px padding-left: 20px padding-right: 20px'" +
95+
"class='videoWrapper'>" + video?.embedCode + "</div>"
96+
}
9097

9198
webViewUtils.initWebView(html, activity)
9299
webView.webChromeClient = fullScreenChromeClient

0 commit comments

Comments
 (0)