代码之家  ›  专栏  ›  技术社区  ›  Tessy Thomas

ClojureScript+React Native-嵌入视频

  •  1
  • Tessy Thomas  · 技术社区  · 6 年前

    我不熟悉ClojureScript。我想使用ClojureScript和React Native将视频(Youtube)嵌入混合移动应用程序。我已尝试实施 反应本机视频 反应本地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"}}]
    

    反应本地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()
    

    我正在使用 莱因 再生的

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

    参考:

    react-native-video

    react-native-youtube

    2 回复  |  直到 6 年前
        1
  •  0
  •   vikeri    6 年前

    在不知道发生了什么错误和设置的情况下,尝试调用以下模块:

    (def Video (aget (js/require "react-native-video") "default"))
    
        2
  •  0
  •   Tessy Thomas    6 年前

    我可以使用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原生视频不支持youtube视频。

    推荐文章