{"id":29060,"date":"2022-07-18T11:02:08","date_gmt":"2022-07-18T11:02:08","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/blog\/?p=29060"},"modified":"2024-06-04T06:14:51","modified_gmt":"2024-06-04T06:14:51","slug":"react-video-player-part-1","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/blog\/react-video-player-part-1","title":{"rendered":"Create React Video Player (Part 1): Beginners\u2019 Guide"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Are you wondering how to implement <b>react video player<\/b> in your application? Do you have a client requirement or want to learn just for yourself? In either case, we are here to help you.<\/p>\n<p>Our team is back with a tutorial for beginners: How to create react video player (part 1). You know the drill, follow the step-by-step instructions till the end and implement with us or clone the source code from the last section. Choose whatever\u2019s best for you and start coding, my friend!<\/p>\n<p>Let\u2019s discuss the goals and prerequisites of the tutorial.<\/p>\n<h2>Tutorial Goal &#038; Prerequisites: <mark>React Video Player<\/mark><\/h2>\n<h3>Tutorial Goals<\/h3>\n<ul class=\"bullets text-left\">\n<li>Basic project set up and installation<\/li>\n<li>Simple demo application with react video player<\/li>\n<li>Source code<\/li>\n<\/ul>\n<p>The video player application is capable of playing videos on this platform:<\/p>\n<ul class=\"bullets text-left\">\n<li>Youtube<\/li>\n<li>Facebook<\/li>\n<li>Vimeo<\/li>\n<li>Dailymotion<\/li>\n<li>Soundcloud<\/li>\n<li>Wistia<\/li>\n<li>Twitcoh<\/li>\n<li>Mixcloud<\/li>\n<\/ul>\n<h3>Prerequisites<\/h3>\n<ul class=\"bullets text-left\">\n<li><u>Basic knowledge of ReactJS<\/u><\/li>\n<li><u>Familiarity with installation dependencies<\/u><\/li>\n<li><u>Familiarity with styling the component and its responsiveness<\/u><\/li>\n<\/ul>\n<p class=\"boxed bg--secondary\" style=\"border: 1px solid #c7c7c7; box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);\"><strong><i><span style=\"font-size:22px; color:#000;\">Save up to 40% on Development, Maintenance, and Support Cost<\/span><br \/>\nContact Us and <a href=\"https:\/\/www.bacancytechnology.com\/hire-reactjs-developer\" target=\"_blank\" rel=\"noopener\">hire Reactjs developers<\/a> to Upscale Your Product Development Capabilities<\/strong><\/i><\/p>\n<h2>Creating a New ReactJS Project<\/h2>\n<p>Use the below command to create a new reactJS project.<\/p>\n<pre>yarn create react-app react-video-player<\/pre>\n<div id=\"attachment_29081\" style=\"width: 1110px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-29081\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Creating-a-new-ReactJS-project-min.jpg\" alt=\"Creating a new ReactJS project\" width=\"1100\" height=\"635\" class=\"size-full wp-image-29081\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Creating-a-new-ReactJS-project-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Creating-a-new-ReactJS-project-min-300x173.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Creating-a-new-ReactJS-project-min-1024x591.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Creating-a-new-ReactJS-project-min-768x443.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><p id=\"caption-attachment-29081\" class=\"wp-caption-text\">Creating a new ReactJS project<\/p><\/div>\n<h2Run Application<\/h2>\n<p>Use the below command to run the application, just to check whether we have create the project successfully or not.<\/p>\n<pre>cd react-video-player\r\nyarn start<\/pre>\n<p>Once we execute the above command our application will run successfully. Here\u2019s the default screen you will see.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"596\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/application-will-run-successfully-min.jpg\" alt=\"application will run successfully\" class=\"alignnone size-medium wp-image-29083\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/application-will-run-successfully-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/application-will-run-successfully-min-300x163.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/application-will-run-successfully-min-1024x555.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/application-will-run-successfully-min-768x416.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<h2>Code Cleaning<\/h2>\n<p>To implement our main functionality using <i>react video player<\/i> we will open App.js file and remove unnecessary code.<\/p>\n<h3>\/\/ App.js<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"335\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Code-Cleaning-min.jpg\" alt=\"Code Cleaning\" class=\"alignnone size-medium wp-image-29082\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Code-Cleaning-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Code-Cleaning-min-300x91.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Code-Cleaning-min-1024x312.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Code-Cleaning-min-768x234.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<h2>Install react-player<\/h2>\n<p>Now for creating a react video player we will at first install react-player package. Use the below command for the same.<\/p>\n<pre>yarn add react-player<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"412\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Install-react-player-min.jpg\" alt=\"Install react-player\" class=\"alignnone size-medium wp-image-29084\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Install-react-player-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Install-react-player-min-300x112.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Install-react-player-min-1024x384.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Install-react-player-min-768x288.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<h2>Let\u2019s Code<\/h2>\n<p>Import react-player package in App.js.<\/p>\n<pre>import ReactPlayer from 'react-player'<\/pre>\n<p>After importing react-player we will make changes in JSX code and for that purpose we will write these lines of code. Your App.js file will look something like this once you are done with adding your code.<\/p>\n<h3>\/\/ App.js<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"365\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/App.js-min.jpg\" alt=\"App.js\" class=\"alignnone size-medium wp-image-29078\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/App.js-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/App.js-min-300x100.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/App.js-min-1024x340.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/App.js-min-768x255.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>Now our demo application will look as shown below.<\/p>\n<div id=\"attachment_29085\" style=\"width: 1110px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-29085\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Demo-video-application-min.jpg\" alt=\"Demo video application\" width=\"1100\" height=\"485\" class=\"size-full wp-image-29085\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Demo-video-application-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Demo-video-application-min-300x132.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Demo-video-application-min-1024x451.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/Demo-video-application-min-768x339.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><p id=\"caption-attachment-29085\" class=\"wp-caption-text\">Demo video application<\/p><\/div>\n<h2>React Video Player Demo App: Set Responsiveness<\/h2>\n<p>Once done with the basic implementation of react video player, we will now code for the application\u2019s responsiveness. For making application responsive we will remove JSX code and then add new lines of code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"335\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/React-Video-Player-Demo-App-Set-Responsiveness-min.jpg\" alt=\"React Video Player Demo App Set Responsiveness\" class=\"alignnone size-medium wp-image-29079\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/React-Video-Player-Demo-App-Set-Responsiveness-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/React-Video-Player-Demo-App-Set-Responsiveness-min-300x91.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/React-Video-Player-Demo-App-Set-Responsiveness-min-1024x312.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/React-Video-Player-Demo-App-Set-Responsiveness-min-768x234.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>And also import the App.css file. So now our App.js will look like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"535\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/import-the-App.css-file-min.jpg\" alt=\"import the App.css file\" class=\"alignnone size-medium wp-image-29080\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/import-the-App.css-file-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/import-the-App.css-file-min-300x146.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/import-the-App.css-file-min-1024x498.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/import-the-App.css-file-min-768x374.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>Open App.css file and clean up previous code. Add these css styles to make application responsive.<\/p>\n<pre>.player-wrapper {\r\n  position: relative;\r\n  padding-top: 56.25% \/* Player ratio: 100 \/ (1280 \/ 720) *\/\r\n}\r\n\r\n.react-player {\r\n  position: absolute;\r\n  top: 0;\r\n  left: 0;\r\n}<\/pre>\n<p>Voila! done with the responsiveness of our react video player demo app! You can see outcome as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"582\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/The-responsiveness-min.jpg\" alt=\"Set Responsiveness\" class=\"alignnone size-medium wp-image-29086\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/The-responsiveness-min.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/The-responsiveness-min-300x159.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/The-responsiveness-min-1024x542.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2022\/07\/The-responsiveness-min-768x406.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<h2>Github Repository: react-video-player-demo<\/h2>\n<p>This way we have successfully implemented video player application in React.js. Feel free to clone the github repository: <a href=\"https:\/\/github.com\/krdheeraj51\/react-video-player\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">react-video-player-demo<\/a> and start exploring more.<\/p>\n<h2>Conclusion<\/h2>\n<p>Since, this was a beginners\u2019 guide we are done with the tutorial here. We will be back with Create React Video Player (Part 2): Intermediate Guide with mode features of previous, next, pause, resume, and many more functionalities. Till then you guys try the beginners\u2019 guide and visit <a href=\"https:\/\/www.bacancytechnology.com\/tutorials\/reactjs\" target=\"_blank\" rel=\"noopener\">ReactJS tutorials page<\/a> for more such interesting and technical tutorials. We are sure you won\u2019t regret it at all! Use your time and start coding! Don\u2019t forget to write us your feedback and questions. We are building a community to serve tech enthusiasts and to share knowledge with the help of different tutorials, your suggestions will help us be better and do better. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Are you wondering how to implement react video player in your application? Do you have a client requirement or want to learn just for yourself? In either case, we are here to help you. Our team is back with a tutorial for beginners: How to create react video player (part 1). You know the [&hellip;]<\/p>\n","protected":false},"author":151,"featured_media":29077,"comment_status":"open","ping_status":"open","sticky":false,"template":"blog-new-template.php","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"_lmt_disableupdate":"no","_lmt_disable":"","footnotes":""},"categories":[988],"tags":[],"coauthors":[2429],"class_list":["post-29060","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react"],"acf":[],"modified_by":"Chandresh Patel","_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/posts\/29060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/users\/151"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=29060"}],"version-history":[{"count":0,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/posts\/29060\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/media\/29077"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=29060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=29060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=29060"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/coauthors?post=29060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}