【问题标题】:How to display the embed video url in Html.FromHTML如何在 Html.FromHTML 中显示嵌入视频 url
【发布时间】:2016-07-25 10:24:16
【问题描述】:

我想使用 Html.FromHTML() 在 android textview 中显示嵌入 URL。

我得到这个 JSON 字符串

"<!DOCTYPE html>\r\n<html>\r\n<head>\r\n</head>\r\n<body>\r\n<p style=\"text-align: justify;\"><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;This video is about hip hop dance done by Amit. He moved his leg from one of the A R Rahman album which Humma Humma song. The steps are too awesome which made you to shake your legs. Watch this to start shake your legs.&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:7043,&quot;3&quot;:{&quot;1&quot;:0},&quot;4&quot;:{&quot;1&quot;:2,&quot;2&quot;:16777215},&quot;10&quot;:0,&quot;11&quot;:4,&quot;12&quot;:0,&quot;14&quot;:{&quot;1&quot;:2,&quot;2&quot;:3355443},&quot;15&quot;:&quot;\\&quot;Arial\\&quot;,\\&quot;sans-serif\\&quot;&quot;}\">This video is about hip hop dance done by Amit. He moved his leg from one of the A R Rahman album which Humma Humma song. The steps are too awesome which made you to shake your legs. Watch this to start shake your legs.</span></p>\r\n<p style=\"text-align: justify;\"><span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;This video is about hip hop dance done by Amit. He moved his leg from one of the A R Rahman album which Humma Humma song. The steps are too awesome which made you to shake your legs. Watch this to start shake your legs.&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:7043,&quot;3&quot;:{&quot;1&quot;:0},&quot;4&quot;:{&quot;1&quot;:2,&quot;2&quot;:16777215},&quot;10&quot;:0,&quot;11&quot;:4,&quot;12&quot;:0,&quot;14&quot;:{&quot;1&quot;:2,&quot;2&quot;:3355443},&quot;15&quot;:&quot;\\&quot;Arial\\&quot;,\\&quot;sans-serif\\&quot;&quot;}\">
<iframe src=\"//www.youtube.com/embed/mhIDO6YMx80\" width=\"560\" height=\"314\" allowfullscreen=\"allowfullscreen\"></iframe></span></p>\r\n</body>\r\n</html>"

我正在使用 Html.FromHTML() 在TextView 中显示此内容。在这我知道&lt;iframe src&gt; 标签在android Html.FromHTML() 中不支持。取而代之的是,我如何显示视频。在 JSON HTML 字符串中,它将图像、文本和视频等等。

请任何人有想法,分享它。提前致谢。

【问题讨论】:

    标签: android html json iframe textview


    【解决方案1】:

    我想在 android textview 中显示嵌入 URL Html.FromHTML().

    你不能。 Html.FromHtml() 不解析/处理 iframe

    我怎样才能显示视频而不是这个

    您必须使用WebView,或者您可以使用YouTube sdk,但有其所有限制

    【讨论】:

    • 我不想使用 webview。看起来不太好。
    • 那么我可以给你的唯一建议就是使用 YouTube sdk 及其所有限制。
    • 我可以使用 Youtube sdk。但在我的场景中,该 Html 内容将包含多个图像文本 herflinks 视频。所以我不能单独获取 url 并将其加载到 sdk 中。基本上来自网站编辑器的用户将编写描述。这样内容就会出现。
    • 最后我使用 webview 并使用websettings 进行风格。谢谢
    猜你喜欢
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 2013-10-26
    • 1970-01-01
    相关资源
    最近更新 更多