如何在Html.FromHTML中显示嵌入的视频网址

时间:2016-07-25 10:24:17

标签: android html json iframe textview

我想使用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>"

我在TextView中使用Html.FromHTML()显示此内容。在此我知道{H} .FromHTML()中不支持<iframe src>标记。而不是这个我怎么能显示视频。在JSON HTML String中,它将成像&amp;文字&amp;视频和所有。

请任何人有想法,分享。在此先感谢。

1 个答案:

答案 0 :(得分:2)

  

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

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

  

而不是这个我如何显示视频

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