mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Base64 encode the subtitle HTML before passing to WebView.loadData
Without this, URL-encoding is assumed, which means ampersand-codes are not carried through to the underlying web page correctly. PiperOrigin-RevId: 304163733
This commit is contained in:
parent
5392a2f4bc
commit
76358d983f
1 changed files with 8 additions and 1 deletions
|
|
@ -23,13 +23,16 @@ import android.content.Context;
|
|||
import android.graphics.Color;
|
||||
import android.text.Layout;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Base64;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -231,7 +234,11 @@ import java.util.List;
|
|||
|
||||
html.append("</div></body></html>");
|
||||
|
||||
webView.loadData(html.toString(), "text/html", /* encoding= */ null);
|
||||
webView.loadData(
|
||||
Base64.encodeToString(
|
||||
html.toString().getBytes(Charset.forName(C.UTF8_NAME)), Base64.NO_PADDING),
|
||||
"text/html",
|
||||
"base64");
|
||||
}
|
||||
|
||||
private String convertAlignmentToCss(@Nullable Layout.Alignment alignment) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue