在本机上看不到嵌入的youtube

时间:2019-05-15 10:18:32

标签: javascript react-native youtube

我正在尝试将嵌入的youtube视频添加到我的react-native-app中,该元素已经过检查,但是没有内容

        String sResponseFromServer = null;
            WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
            tRequest.Method = "post";
            //serverKey - Key from Firebase cloud messaging server  
            tRequest.Headers.Add(string.Format("Authorization: key={0}", ServerID));
            //Sender Id - From firebase project setting  
            tRequest.Headers.Add(string.Format("Sender: id={0}", "8644xxxxxxx"));
            tRequest.ContentType = "application/json";
            var payload = new
            {
                to = "/topics/android",
                priority = "high",
                content_available = true,
                data = new
                {
                    body = "Greetings",
                    title = "Push Notification",
                    sound = "Enabled"
                },
            };

            string postbody = JsonConvert.SerializeObject(payload).ToString();
            Byte[] byteArray = Encoding.UTF8.GetBytes(postbody);
            tRequest.ContentLength = byteArray.Length;
            using (Stream dataStream = tRequest.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
                using (WebResponse tResponse = tRequest.GetResponse())
                {
                    using (Stream dataStreamResponse = tResponse.GetResponseStream())
                    {
                        if (dataStreamResponse != null) using (StreamReader tReader = new StreamReader(dataStreamResponse))
                            {
                                sResponseFromServer = tReader.ReadToEnd();
                                //result.Response = sResponseFromServer;
                            }
                    }
                }
            }
            return Ok(sResponseFromServer);

enter image description here

1 个答案:

答案 0 :(得分:0)

我尝试在youtube URL中使用您的视频ID,但该视频不可用(可能是私有的或各种原因)。

尝试使用示例视频ID,看看是否有效:KVZ-P-ZI6W4 另外,请确保您的网络连接正常。

<YouTube
  videoId="KVZ-P-ZI6W4"   // The YouTube video ID
  play={true}             // control playback of video with true/false
  fullscreen={true}       // control whether the video should play in fullscreen or inline
  loop={true}             // control whether the video should loop when ended

  onReady={e => this.setState({ isReady: true })}
  onChangeState={e => this.setState({ status: e.state })}
  onChangeQuality={e => this.setState({ quality: e.quality })}
  onError={e => this.setState({ error: e.error })}

  style={{ alignSelf: 'stretch', height: 300 }}
/>