ClojureScript + React-Native-嵌入视频

时间:2018-11-15 10:42:44

标签: react-native clojurescript react-native-video cljsrn re-natal

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

使用本机视频

(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应用。

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

参考:

react-native-video

react-native-youtube

2 个答案:

答案 0 :(得分:0)

在不知道遇到什么错误以及设置有什么错误的情况下,请尝试改为调用此类模块:

(def Video (aget (js/require "react-native-video") "default"))

答案 1 :(得分:0)

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

(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视频。