首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在React中添加cloudinary playList小部件

在React中添加cloudinary playList小部件
EN

Stack Overflow用户
提问于 2020-09-08 12:00:19
回答 2查看 242关注 0票数 0

我有来自cloudinary的运行视频的React应用程序。我已经设法编辑视频标签,但也想添加playlistWidget。这在code/Video标签中的位置合适吗?cloudinary上提供的示例是针对javascript的,而不是React。

https://cloudinary.com/documentation/video_player_customization

这是我的cloudinary player组件的示例。

代码语言:javascript
复制
import React from "react";
import axios from "axios";
import "./VideoPlayer.css"
import { inDev } from "../API";
const devAPI = "http://localhost:8081/api/";
const baseAPI = "api/";
import {Image, Video, Transformation, CloudinaryContext} from 'cloudinary-react'; 



class Player extends React.Component { 

    constructor(props) {
        super(props);
        this.state = {
          WelcomeVideo:"https://res.cloudinary.com/Name/video/upload/v1594509086/ab7qqxjexpwfv4j7kzj2x.mp4",
          Logo:"https://res.cloudinary.com/example/image/upload/v1599423081/Logo1.png",
           
        };

     
    
      }
    
    render() {

return ( <div style={{textAlign: "center"}}> 
<h1 style={{fontSize:"60px"}}>Video of Week!</h1>



<Video
id="example-player"
cloudName="demo" 
src={this.state.WelcomeVideo} 
publicId="cat" 
controls 
autoPlay="true"
preload= "auto"
class="cld-video-player"
poster={this.state.Logo}
width= "400"
height="320"
fallback="Cannot display video" 
/> 


                     
                  

</div> 
    );
}
}


export default Player;

更新了每个cloudinary https://cloudinary.com/documentation/video_player_playlists_recommendations#:~:text=playlist%20widget%20%2D%20A%20scrollable%20list,a%20full%20screen%20web%20browser的建议。

代码语言:javascript
复制
import React, { Component } from "react";
import { Cloudinary } from "cloudinary-core";
import "cloudinary-video-player/dist/cld-video-player";

class PlayerCloud extends Component {


  componentDidMount() {
// Setting video sources:
var source1 = { publicId: 'elephants', info: { title: 'My main movie', 
   subtitle: 'Something to know about the main movie' } }
var source2 = { publicId: 'cat', info: { title: 'Another great video', 
   subtitle: 'A great subtitle', 
   description: 'An interesting description of this video....' } }
var source3 = { publicId: 'dog', info: { title: 'Another interesting video1', 
   subtitle: 'Subtitle for video3', description: 'An interesting description of this video....' } }
 
   // Specifying the recommendations for source1 as a fixed array of sources:
source1.recommendations = [source2, source3]

    const cld = new Cloudinary({ cloud_name: "demo", secure: true });
    const videoName = "elephants";
   var demoplayer = cld.videoPlayer("some-video", {
      publicId: source1.publicId,
      controls: true,
      preload: "auto",
      muted: true,
      autoplay: true,
      width: 300,
      autoShowRecommendations:true 
    });
   
  }
  render() {
    return (
      <div>
        <video
        id="some-video"
        />
      </div>
    );
  }
}
export default PlayerCloud;
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-09-08 23:04:21

请参阅此Codesandbox,展示如何将视频播放器代码绑定到视频标签。一旦您运行的是视频播放器而不是HTML5视频标记,就可以添加像playList小部件这样的功能

https://codesandbox.io/s/em2g0

https://cloudinary.com/documentation/video_player_playlists_recommendations#creating_a_playlist

视频播放器需要index.html中的CSS以及绑定到视频标签的功能。

票数 0
EN

Stack Overflow用户

发布于 2020-09-30 07:28:45

这是另一个react Sandbox,它只是在视频播放器中显示一个短视频。https://codesandbox.io/s/react-cld-video-player-v2-yfgxi?file=/src/VideoPlayerTest.js

您可以在此处找到有关视频播放器选项和样式的更多信息:https://cloudinary.com/documentation/cloudinary_video_player

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63786919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档