ClojureScript + React-Native-嵌入视频 [英] ClojureScript + React-Native - Embed Videos

查看:174
本文介绍了ClojureScript + React-Native-嵌入视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ClojureScript的新手。我想使用ClojureScript和React Native将视频(Youtube)嵌入到混合移动应用程序中。我试图在ClojureScript中实现 react-native-video react-native-youtube 插件以实现此目的。但是,这些都以崩溃告终。我不知道引用库是否有问题。

I am new to ClojureScript. I would like to embed video (Youtube) to the hybrid mobile app using ClojureScript and React Native. I have tried to implement react-native-video and react-native-youtube plugins in ClojureScript for achieving this. But, both of these end with a crash. I don't know whether there is something wrong with referring to the library or not.

使用 react-native-video

(def Video (js/require "react-native-video"))
(def video-view (r/adapt-react-class Video))

组件引用为:

[video-view {:style {:position "absolute"
                            :top 0
                            :bottom 0
                            :left 0
                            :right 0}
                      :source {:uri "https://www.youtube.com/watch?v=M8Fn8SfXw3M"}}]

使用 react-native-youtube

(def YouTube (js/require "react-native-youtube"))
(def video-view (r/adapt-react-class YouTube))

组件参考:

[video-view {:style {:flex 1
                              :margin-bottom 60
                              :padding-top 10
                              :padding-bottom 10}
                      :video-id "M8Fn8SfXw3M"
                      :play true
                      :fullscreen true
                      :loop true}]

这两个选项均无效。

以下是崩溃报告:

> Invariant Violation: Element type is invalid: expected a string (for
> built-in components) or a class/function (for composite components)
> but got: object This error is located at:
>      in RCTView
>      in RCTView
>      in RCTScrollView
>      in ScrollView
>      in t
>      in RCTView
>      in :page-art-single
>      in RCTView
>      in .a
>      in RCTView
>      in :main
>      in py
>      in RCTView
>      in RCTView
>      in t  Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite
> components) but got: object.    This error is located at:
>      in RCTView
>      in RCTView
>      in RCTScrollView
>      in ScrollView
>      in t
>      in RCTView
>      in :page-art-single
>      in RCTView
>      in .a
>      in RCTView
>      in :main
>      in py
>      in RCTView
>      in RCTView
>      in t  undefined is not an object (evaluating 'this.map.setNativeProps') D/ReactNative(15325):
> ReactInstanceManager.detachViewFromInstance()

我正在使用 lein 编译ClojureScript Re-Natal 用于构建基于ClojureScript的React Native应用。

I am using lein for compiling ClojureScript Re-Natal for building this ClojureScript-based React Native app.

上面的代码有什么问题吗?有人,请帮忙?

Is there anything wrong with the above code? Anyone, please help?

参考:

反应本机视频

react-native-youtube

推荐答案

我可以使用ReactNative WebView嵌入YouTube视频。

I could embed YouTube video by using ReactNative WebView.

(def ReactNative (js/require "react-native"))
(def web-view (r/adapt-react-class (oget ReactNative "WebView")))

组件参考:

[web-view { :style {
                            :width 400
                            :height 200
                            :zIndex 10}
                      :javaScriptEnabled true
                      :domStorageEnabled true
                      :source {:uri "https://www.youtube.com/embed/M8Fn8SfXw3M"}}]

我认为react-native-video不支持youtube视频。

I think react-native-video is not supporting youtube videos.

这篇关于ClojureScript + React-Native-嵌入视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆