Youtube嵌入式视频问题(视频不可用)

问题描述 投票:0回答:1

当我想在我的博览会应用程序中嵌入YouTube视频时遇到问题,当我点击播放按钮时,我有时会收到以下消息:

unavaible_message_from_youtube

例如,当我在reddit上发布这个视频时,它通过他们的youtube嵌入式播放器完美播放。

我使用这个代码示例:

              <WebView
                useWebKit={true}
                ref={(ref) => { this.videoPlayer = ref;}}
                source={{uri: 'https://www.youtube.com/embed/bo_efYhYU2A?rel=0&autoplay=0&showinfo=0&controls=0'}}
                scrollEnabled={false}
                domStorageEnabled={true}
                javaScriptEnabled={true}
              />

我知道视频是允许嵌入的,因为当不是这种情况时,我得到一个不同的错误信息,允许我在youtube上打开视频:screenshot_disable_embedded

这是测试它的链接:https://snack.expo.io/@maxgfr/youtube-embedded

任何帮助将不胜感激

马克西姆

编辑:不起作用的网址示例https://www.youtube.com/embed/8GaWM2a3FAc

webview youtube youtube-api youtube-data-api youtube-javascript-api
1个回答
0
投票

要解决这个问题:

我创建了一个Web应用程序,它可以通过视频ID加载YouTube视频。我的终点是这样的:https://mywebsite.com/ID_VIDEO_YOUTUBE

然后在我的本机应用程序中,我只需要加载我的网站的URL:

<WebView
   useWebKit={true}
   ref={(ref) => { this.videoPlayer = ref;}}
   source={{uri: 'https://mywebsite.com/ID_VIDEO_YOUTUBE'}}
   scrollEnabled={false}
   domStorageEnabled={true}
   javaScriptEnabled={true}
/>

编辑:这是我在Vue JS应用程序中使用的代码示例

<template>
  <div style="position: fixed;overflow-y: hidden;overflow-x: hidden;width:100%;height:100%;">
    <iframe style="width:100%;height:100%;" :src="'https://www.youtube.com/embed/'+this.$route.params.id+'?&autoplay=1&playsinline=1'" autoplay="1" playsinline="1" frameborder="0" scrolling="no" allow="playsinline; accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>
</template>

<script>
export default {
  name: 'youtube',
  head: {
    link: [{
      r: 'icon',
      h: '/static/favicon.png',
      t: 'image/png'
    }]
  }
}
</script>
© www.soinside.com 2019 - 2024. All rights reserved.