【问题标题】:Single Youtube Video Embedding in Xamarin Forms but Not Youtube list单个 Youtube 视频嵌入 Xamarin 表单但不是 Youtube 列表
【发布时间】:2017-07-24 11:57:27
【问题描述】:

我想将 Youtube 视频集成到 Xamarin.forms 应用程序中。

目前我已经用谷歌搜索并找到了以下链接:

https://www.thewissen.io/embedding-youtube-feed-xamarin-forms/

XAMARIN - add video from youtube

但他们只处理 Youtube 列表,而不是单个 Youtube 视频。

我想要一个不在WebView 中播放的视频

我该如何解决这个问题?

【问题讨论】:

  • @user1,有什么线索吗?
  • 我会查看Rox.VideoPlayer nugetXamarin Video Player,它们似乎都允许您从 youtube 流式传输。虽然第二个链接需要 50 美元。但是第一个是免费的
  • 我已经看到了第二个链接,我想要这个免费的,无论如何让我看看第一个谢谢
  • 第一个不支持youtube,如果你知道它是如何与youtube一起工作的,请帮助
  • 你找到了一个好的解决方案吗?

标签: c# xamarin xamarin.forms youtube-api


【解决方案1】:
HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();
personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
personHtmlSource.Html = @"<html><body>  <div style=' position: relative; padding-bottom: 56.25%; padding-top: 25px;'> <iframe style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'  src='https://www.youtube.com/embed/bVdfj7HXuXE' frameborder='0' allowfullscreen></iframe></div> </body></html>";
var browser = new WebView();
browser.Source = personHtmlSource;
Content = browser;

【讨论】:

    【解决方案2】:

    就这样吧!!

    <WebView VerticalOptions="FillAndExpand"
            HorizontalOptions="FillAndExpand"
            Source="https://www.youtube.com/embed/8azMAqsuHs0"
            WidthRequest="500"
            HeightRequest="500"
            IsVisible="true"/>
    

    记得设置宽高是必须的,否则不显示!

    最好的问候

    【讨论】:

      猜你喜欢
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 2020-07-24
      • 2023-03-17
      • 2012-10-01
      • 2021-12-04
      • 2012-06-25
      • 1970-01-01
      相关资源
      最近更新 更多