<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joaquin Viera, Author at asap developers</title>
	<atom:link href="https://www.asapdevelopers.com/author/joaco-viera/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.asapdevelopers.com/author/joaco-viera/</link>
	<description>San Francisco Mobile App Developers</description>
	<lastBuildDate>Mon, 25 Oct 2021 20:29:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://www.asapdevelopers.com/wp-content/uploads/2017/04/favicon-asap-1.png</url>
	<title>Joaquin Viera, Author at asap developers</title>
	<link>https://www.asapdevelopers.com/author/joaco-viera/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Build a Global Activity Feed with React Native and Node.js</title>
		<link>https://www.asapdevelopers.com/build-a-global-activity-feed-with-react-native-and-node-js/</link>
		
		<dc:creator><![CDATA[Joaquin Viera]]></dc:creator>
		<pubDate>Mon, 25 Oct 2021 20:15:50 +0000</pubDate>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[React Native]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=14963</guid>

					<description><![CDATA[<p>People around the globe use Facebook, Instagram, Pinterest, Twitter and many other popular applications every day. They’re all used for different purposes like staying in touch with friends, creating blogs,...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/build-a-global-activity-feed-with-react-native-and-node-js/">Build a Global Activity Feed with React Native and Node.js</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[


<p>People around the globe use Facebook, Instagram, Pinterest, Twitter and many other popular applications every day. They’re all used for different purposes like staying in touch with friends, creating blogs, posting pictures, or discovering ideas. However, one thing that users of these apps have in common is that every single day they scroll through the apps’ activity feeds searching for new updates. A global activity feed is like a forum where users can post photos or make comments, as well as keep track of recent news or friends and family&#8217;s lives. In this article, we’ll be focusing on how to build one using React Native and Node.js. </p>









<h2><img decoding="async" loading="lazy" class="size-medium wp-image-14970 aligncenter" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/hamburger-menu-300x268.png" alt="Image1 - Global activity" width="300" height="268" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/hamburger-menu-300x268.png 300w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/hamburger-menu.png 360w" sizes="(max-width: 300px) 100vw, 300px" /></h2>



<h2><strong>Before we start</strong></h2>



<p>Adding a global activity feed to a mobile application sounds difficult, but, luckily for us, there are third-party libraries to help us, which is one of the things that we like most about React Native.</p>



<p>Today, we’ll use <a href="https://github.com/GetStream/react-native-activity-feed"><strong>react-native-activity-feed</strong></a> and also, as the documentation states, we’ll need to include the <a href="https://github.com/ivpusic/react-native-image-crop-picker"><strong>react-native-image-crop-picker</strong></a> if we are using native packages or <a href="https://docs.expo.dev/versions/latest/sdk/imagepicker/"><strong>expo-image-picker</strong></a> if we are using Expo.</p>



<p>To install all of these libraries, run the following scripts on your terminal from your React Native root project folder.</p>



<p>If you are using Expo:</p>



<ul>
<li>expo install expo-activity-feed expo-permissions expo-image-picker</li>
</ul>



<p>If you are using native packages:</p>



<ul>
<li>npm install react-native-activity-feed <strong>OR</strong> yarn add react-native-activity-feed</li>
<li>npm install react-native-image-crop-picker <strong>OR</strong> yarn add react-native-image-crop-picker</li>
</ul>



<p>Remember that, if you are using Xcode, every time you add new libraries to your project you have to run <strong>npx pod-install </strong>to install pods dependencies.</p>



<p><strong>Important note</strong>: to use react-native-activity-feed you need to have a GetStream account (we’ll look at this in the following steps). That said, GetStream provides <a href="https://getstream.io/activity-feeds/pricing/"><strong>paid plan options</strong></a> to use its resources; you can still use the Activity Feed package for free for development purposes, but only for a limited time.</p>



<h2><strong>Let’s jump into the code of a Global Activity Feed using React Native</strong></h2>



<p>First of all, you need to create a React Native project.</p>



<p>If you don&#8217;t know how to create your app, just run the following commands on your terminal:</p>



<ul>
<li><a href="https://reactnative.dev/docs/environment-setup"><strong>npx react-native init ProjectName</strong></a></li>
</ul>



<p>Now that you’ve created the application, let’s get to coding!</p>



<p><strong>Important note: </strong>this example was made using React Native 0.66.</p>



<h3> </h3>



<h3><strong>First steps</strong></h3>



<p>First, we need to create an account on <a href="https://getstream.io/accounts/signup/"><strong>https://getstream.io/accounts/signup/</strong></a></p>



<p>After signing up, we’ll navigate to our dashboard where we’ll see that an application has already been created for us. This app includes an App ID, a Key and a Secret Key. We will use those values later.</p>



<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone" src="https://lh6.googleusercontent.com/qViCDXFGAb2gbLjAwve_NGmfuji3yoLpAF-Hg3-d1zcJJcTnYZAEp51ezD4Dn6cWLPK9wJ4AaUdvE-IYpcfTCZS1UQLkZf3y_slZbd0Mf4QFL6poas7AmQR1IdsMxvj2pSBjl003=s1600" alt="global activity feed using react native" width="596" height="403" /></figure>



<p>By clicking on “PRODUCTION APP”, we can access our ‘Feeds’, access keys and other information. Note that we can create new feeds in this section.</p>



<h3><strong>Express backend client</strong></h3>



<p>It is very important to know that we can’t use our Secret Key inside a desktop/mobile/web environment, so we need a backend client.</p>



<p>Therefore, in a separate folder from the one containing the mobile project, we will run <strong>npm init </strong>in our console and provide a project name (e.g.: backend-server).</p>



<p>Inside this folder we need to install the two libraries using the following commands:</p>



<ul>
<li>npm install express &#8211;save</li>
<li>npm install getstream</li>
</ul>



<p>&nbsp;</p>

<p><script src="https://gist.github.com/joaquin-viera/b0ec34861539bd6c41f53fc993715dda.js"></script></p>
<p><b>Link:</b> <a href="https://gist.github.com/joaquin-viera/b0ec34861539bd6c41f53fc993715dda"><span style="font-weight: 400;">Backend.js</span></a></p>

<p>This Express server is very minimalist and its main purpose is to allow us to create a user token for the frontend application. Keep in mind that we are always creating and or getting and subscribing to the feed using a user with id ‘tester’. If we want to add more users, we can change this or send the param inside a query param.</p>



<p>With the server running, now we have to fetch a request to, in this case, <a href="http://localhost:3000">http://localhost:3000</a> from the mobile application.</p>



<h3><strong>Mobile application</strong></h3>



<p>&nbsp;</p>
<p><script src="https://gist.github.com/joaquin-viera/d92f90dad3ac2e717c8ac607f7f6ac03.js"></script></p>
<p><b>Link:</b> <a href="https://gist.github.com/joaquin-viera/d92f90dad3ac2e717c8ac607f7f6ac03"><span style="font-weight: 400;">App.js</span></a></p>

<p>In this example, we have an activity indicator running while we get the user access token to start our StreamApp. The only two values we have here are the STREAM_API_KEY and STREAM_APP_ID; the token is the one that we got from the backend.</p>



<p>GetStream provides <a href="https://github.com/GetStream/react-native-activity-feed/tree/master/src/components">many components</a> to use and customize. The most important one to establish the connection to our feed is <strong>StreamApp</strong>, which includes the API key, the app ID and a private token. We also need to send our user ID to see our user information in the post we create.</p>



<p>We can customize our feed however we want. We can also copy/paste the GetStream components to our code and make some modifications. In this example, we’ll customize the UserBar component for every Activity, and we’ll also add a LikeButton easily and in just a few lines as you can see in the link above!</p>



<p>Finally, we will see how the notify prop on the FlatFeed component shows that, every time there is a new post available, we will be notified and can tap on the notification area to see the new posts. If we prefer swiping down to update the feed, we can set the notify prop to false.</p>



<h2> </h2>



<h2><strong>Global Activity Feed preview</strong></h2>





<figure class="wp-block-image"><img decoding="async" loading="lazy" class="alignnone  wp-image-14971" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone1AG-143x300.png" alt="global activity feed - image1" width="288" height="604" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone1AG-143x300.png 143w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone1AG.png 220w" sizes="(max-width: 288px) 100vw, 288px" /><img decoding="async" loading="lazy" class="alignnone  wp-image-14972" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone2AG-143x300.png" alt="global activity feed - image2" width="288" height="604" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone2AG-143x300.png 143w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone2AG.png 255w" sizes="(max-width: 288px) 100vw, 288px" /><img decoding="async" loading="lazy" class="alignnone  wp-image-14979" src="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone3AG-1-142x300.png" alt="phone2 - global activity feed" width="286" height="604" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone3AG-1-142x300.png 142w, https://www.asapdevelopers.com/wp-content/uploads/2021/10/phone3AG-1.png 322w" sizes="(max-width: 286px) 100vw, 286px" /></figure>
<p>&nbsp;</p>
<p>&nbsp;</p>



<figure class="wp-block-image"></figure>



<h2><strong>Final thoughts on building a Global Activity Feed using React Native</strong></h2>



<p>As we&#8217;ve seen, adding an activity feed to our <a href="https://www.asapdevelopers.com/react-native-san-francisco/">React Native</a> application can be done with just a few lines of code and it is not as hard as it might seem.</p>



<p>The best advantages of this library are that it is easy to use, it is easy to adapt and customize to our designs, and it provides many other features to use in our development projects.</p>

		<div id="fws_693977483ac4e"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row top-level standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/react-native-san-francisco/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>Mobile App Development Company</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/build-a-global-activity-feed-with-react-native-and-node-js/">Build a Global Activity Feed with React Native and Node.js</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>React Native Live Stream Video</title>
		<link>https://www.asapdevelopers.com/react-native-live-stream-video/</link>
		
		<dc:creator><![CDATA[Joaquin Viera]]></dc:creator>
		<pubDate>Mon, 16 Aug 2021 20:59:27 +0000</pubDate>
				<category><![CDATA[React Native]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=14780</guid>

					<description><![CDATA[<p>Streaming is something that we see every day at all times in applications such as Instagram, Tik Tok, Twitter, Twitch and Youtube.  Having a streaming functionality in an application sounds...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/react-native-live-stream-video/">React Native Live Stream Video</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><img decoding="async" loading="lazy" class="aligncenter" src="https://lh6.googleusercontent.com/W9ocTB0LfjZLfwLj7VuDvBTQANmx6rhgnS6-wZMlZEPPgOA5E0HSlYdZKpAzhc6cOpJTYFpf_56melKfNzHhJESnuhfa6EstbzmLC5eeC1bXyxj6PDYE-CaFQ7JF2kaqHErdChXY" alt="React Native Live Stream Video" width="256" height="256" /></p>





<p>Streaming is something that we see every day at all times in applications such as Instagram, Tik Tok, Twitter, Twitch and Youtube.  Having a streaming functionality in an application sounds a bit difficult. However, luckily for us, with <a href="https://reactnative.dev/"><strong>React Native</strong></a> live stream video and a third-party libraries, things are much easier. So let’s take a look at how to add a live stream video functionality to an app.</p>





<h2><strong>Requirements for React Native live stream video</strong></h2>



<p>In this project, we will use the <a href="https://github.com/NodeMedia/react-native-nodemediaclient"><strong>react-native-nodemediaclient</strong></a> library.</p>



<p>So, after running “<a href="https://reactnative.dev/docs/0.60/getting-started"><strong>npx react-native init ProjectName</strong></a>” and creating our project, we will go to our project’s root folder and install the library running one of the following commands in our console:</p>



<ul>
<li>npm install react-native-nodemediaclient </li>
</ul>



<h4><strong>OR</strong> </h4>



<ul>
<li>yarn add react-native-nodemediaclient</li>
</ul>



<p>If we are using a Mac environment we’ll go to the iOS folder and install the pod dependencies by just running the following commands:</p>



<ul>
<li>cd ios</li>
<li>pod install</li>
</ul>



<p>One last thing we must do is grant camera permissions for our project.</p>



<p>For Android, just add the following lines to <strong>ProjectName/android/app/src/main/AndroidManifest.xml</strong> :</p>

<p><script src="https://gist.github.com/joaquin-viera/203514be4286ab52e63dc110b34ccaf7.js"></script> <b>Link:</b> <a href="https://gist.github.com/joaquin-viera/203514be4286ab52e63dc110b34ccaf7"><span style="font-weight: 400;">script</span></a></p>

<p>For iOS, add the following lines to <strong>ProjectName/ios/QLive/Info.plist</strong>:</p>

<p><script src="https://gist.github.com/joaquin-viera/ed3f58eba697fc788b5bfe3985a05de0.js"></script> <b>Link:</b> <a href="https://gist.github.com/joaquin-viera/ed3f58eba697fc788b5bfe3985a05de0"><span style="font-weight: 400;">script</span></a></p>

<p>Now, our environment is ready and we can proceed with the application development.</p>



<h2><strong>Let’s jump into the code</strong></h2>



<p>In our application, we will have 3 screens:</p>



<ol>
<li>Main screen</li>
<li>Streaming screen</li>
<li>Play Stream screen</li>
</ol>



<p><strong>Note: </strong>This implementation was written using functional components and hooks.</p>



<h3><strong>Main screen</strong></h3>



<p>This is the screen we will see when our application starts. The function <strong>“requestCameraPermission”, </strong>as the name indicates, will ask our device to grant Camera and Record Audio permissions.</p>



<p>The useState hooks are used to store the Stream player and Live Session server URLs.</p>



<p>The useEffect hook uses the request permissions function on Android devices (using the Platform API) when our component mounts for the first time.</p>



<p>Then, there’s the screen container where we have an input to write the streaming name that we will place at the end of the URLs.</p>



<p>At the bottom of the screen, we have two buttons to go to the other two screens.</p>



<p>Finally, we have a navigation component to navigate inside our application.</p>

<p><script src="https://gist.github.com/joaquin-viera/10988aab80919f1a29bf4479a20f1e3f.js"></script> <b>Link:</b> <a href="https://gist.github.com/joaquin-viera/10988aab80919f1a29bf4479a20f1e3f"><span style="font-weight: 400;">script</span></a></p>

<h3><strong>Streaming screen</strong></h3>



<p>This screen is where we will use our mobile’s front or back camera to start streaming.</p>



<p>Keep in mind that the first time we get to this screen or the Play Stream one, we will be asked to grant Camera and Audio permissions. </p>



<p>We use a useState hook to set a reference to the NodeCameraView component and the useEffect hook to stop the streaming content once we get on the screen.</p>



<p>Inside the NodeCameraView component, we have props that we can use to adjust the audio definition, video resolution, the available cameras, and much more.</p>



<p>One important prop of this component is <strong>outputUrl, </strong>which is where we set the URL and ports where our streaming will be played so others can join it.</p>



<p>At the end of the component we have three buttons with the following functions:</p>



<ol>
<li>Switch between the front and back camera.</li>
<li>Start the stream transmission or stop it.</li>
<li>Return to the Main screen.</li>
</ol>

<p><script src="https://gist.github.com/joaquin-viera/b8aca9d06c545fc9c25a3b272dc5d069.js"></script> <b>Link:</b> <a href="https://gist.github.com/joaquin-viera/b8aca9d06c545fc9c25a3b272dc5d069"><span style="font-weight: 400;">script</span></a></p>

<h3><strong>Play React Native Live Stream screen</strong></h3>



<p>On this last screen, we can use the useState and useEffect hooks to get and set the component reference, but in this case, we’ll use NodePlayerView.</p>



<p>As the name states, this component is used to see streaming content. On its <strong>inputUrl </strong>prop, we will set the URL from the streaming that we want to watch.</p>



<p>Our example sets the URL from the input on the Main screen where we can write the name of the Stream we would like to join.</p>



<p>Other props that NodePlayerView has are the autoplay option, buffer time and max buffer time; these last two can be used to adjust the transmission if the video is getting some delay. </p>



<p>The onStatus prop is used in this example to display the streaming state on the console, so we will be able to see when the transmission is finished or when we disconnect from it. </p>



<p>Keep in mind that if we set a wrong URL or the transmission is finished, we will see a black screen.</p>



<p>At the end of the component, we have a back button to return to the Main screen.</p>

<p><script src="https://gist.github.com/joaquin-viera/dc96849c2bf0cdd50bea65ffdd571840.js"></script> <b>Link:</b> <a href="https://gist.github.com/joaquin-viera/dc96849c2bf0cdd50bea65ffdd571840"><span style="font-weight: 400;">script</span></a></p>
<p>&nbsp;</p>

<h2><strong>Application preview</strong></h2>



<p><img decoding="async" loading="lazy" class="alignnone" src="https://lh4.googleusercontent.com/7oiX8HhIcGNPT8xOfl6GNTaqu-vKzWJ_0xQR-v_xasF46Yuf0LW9u2HkJUKWLOYzBkjG6rdkaNy0dKpldejwCROtMuq2FMo1V8uMPwyRs9gerZSw0FSFsyR5AX6Q2FAXIkZM09sx" alt="React Native Live Stream Video - EXAMPLE" width="285" height="580" /><img decoding="async" loading="lazy" class="alignnone" src="https://lh4.googleusercontent.com/7Gl2qls7SQAJevuXXYFD5kOSWll5mYm_ubw4DTtKSot1g13ZKh6G2S9rWBz_ZqVsdXbfIQwCMX3tXxt_PqVB3bUgtVuwZFauX3SfoWbuPfGlekQa2mWqpogRvLHsPWZ1HrXa7A8i" alt="React Native Live Stream Video - EXAMPLE2" width="281" height="580" /></p>



<h2> </h2>



<h2><strong>Final thoughts on React Native Live Stream Video</strong></h2>



<p>One of the best things about <a href="https://www.asapdevelopers.com/?s=react+native">React Native</a> is that there are always third-party libraries that make things easier for us. As we have seen in this example, integrating streaming features into our applications was quite simple thanks to the <a href="https://github.com/NodeMedia/react-native-nodemediaclient"><strong>Node Media Client</strong></a> library. Are you ready to try it out?</p>

		<div id="fws_693977483beeb"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/react-native-san-francisco/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>React Native Development Company</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>


<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/react-native-live-stream-video/">React Native Live Stream Video</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>React native ‌orientation‌ locker and ‌landscape‌ orientation</title>
		<link>https://www.asapdevelopers.com/react-native-video-with-landscape-orientation/</link>
		
		<dc:creator><![CDATA[Joaquin Viera]]></dc:creator>
		<pubDate>Mon, 25 Jan 2021 19:46:42 +0000</pubDate>
				<category><![CDATA[React Native]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=14172</guid>

					<description><![CDATA[<p>React Native Video With Landscape Orientation In a previous post, we explained how to add and set up a video player in your React Native application. This time around, we’ll...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/react-native-video-with-landscape-orientation/">React native ‌orientation‌ locker and ‌landscape‌ orientation</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>React Native Video With Landscape Orientation</h2>
<p align="left">In a <a href="https://www.asapdevelopers.com/react-native-video-media-controls-example/"><span style="color: #1155cc;"><u>previous post</u></span></a>, we explained how to add and set up a video player in your React Native application. This time around, we’ll show you how to add full-screen landscape orientation to your video player and use the library React Native Orientation Locker.</p>
<h2><b>Before we start with React Native Video </b></h2>
<p align="left">Keep in mind that the project files are in the initial post mentioned above. This post will pick up from where we left off on that article. We will use a new library to control our mobile screen orientation called ‘<b>React Native Orientation Locker</b>’.</p>
<p align="left"><b>Note: </b>This demo was made with React Native version 63.3. The following setup applies only to React Native versions higher than 60.0. The setup instructions for older versions can be found on the official library documentation.</p>
<p><img decoding="async" loading="lazy" class="aligncenter wp-image-14177 size-medium" src="https://www.asapdevelopers.com/wp-content/uploads/2021/01/flip-289x300.png" alt="React Native Orientation Locker - Video Flip " width="289" height="300" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/01/flip-289x300.png 289w, https://www.asapdevelopers.com/wp-content/uploads/2021/01/flip.png 565w" sizes="(max-width: 289px) 100vw, 289px" /></p>
<h2><b>Let’s setup Orientation Locker</b></h2>
<p>&nbsp;</p>
<p align="left">First of all, you’ll need to add the library to the project using one of the following commands in your terminal:</p>
<ul>
<li>
<p align="left">yarn add react-native-orientation-locker</p>
</li>
<li>
<p align="left">npm i react-native-orientation-locker</p>
</li>
</ul>
<p align="left">For iOS devices, you’ll need to run the following command on Mac inside the ‘iOS’ project folder:</p>
<ul>
<li>
<p align="left">pod install</p>
</li>
</ul>
<p align="left">Next, you&#8217;ll need to manually modify some Android and iOS files to add some lines of code following the instructions below.</p>
<h2 class="western"><b>iOS setup</b></h2>
<p align="left">For iOS, you will need to modify the following file:</p>
<ul>
<li>
<h3><strong>AppDelegate.m</strong></h3>
</li>
</ul>
<p><script src="https://gist.github.com/joaquin-viera/946b697d774466f3a6ea4a2c922b8380.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/946b697d774466f3a6ea4a2c922b8380"><span style="font-weight: 400;">AppDelegate.m</span></a></p>
<p>&nbsp;</p>
<h2 class="western"><b>Android setup</b></h2>
<p>For Android, you will need to modify the following file:</p>
<ul>
<li>
<h3><strong>MainActivity.java</strong></h3>
</li>
</ul>
<p><script src="https://gist.github.com/joaquin-viera/fc77932532eea6fe42e9fc0a8d02eaaa.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/fc77932532eea6fe42e9fc0a8d02eaaa"><span style="font-weight: 400;">MainActivity.java</span></a></p>
<p>&nbsp;</p>
<ul>
<li class="western">
<h3><strong>MainApplication.java</strong></h3>
</li>
</ul>
<p align="left"><b>Note</b>: these changes should appear <u>automatically</u>, but if they don’t, you should make them yourself.</p>
<p><script src="https://gist.github.com/joaquin-viera/d89b1a6c4acd5659c3b1f1f14b040c67.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/d89b1a6c4acd5659c3b1f1f14b040c67"><span style="font-weight: 400;">MainApplication.java</span></a></p>
<p>&nbsp;</p>
<h2><b>Final changes</b></h2>
<p align="left">Now it’s time to make some changes to the <b>VideoPlayer.js</b> file.</p>
<p align="left">It should look something like this:</p>
<p><script src="https://gist.github.com/joaquin-viera/bd864134dd0f3b7c88faf2f9a0536f32.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/bd864134dd0f3b7c88faf2f9a0536f32"><span style="font-weight: 400;">VideoPlayer.js</span></a></p>
<p align="left">As you can see, there is a new useState hook to check if the video player is in full-screen mode. The ‘onFullScreen’ function will be triggered when the user presses the full-screen button or when they exit full-screen mode.</p>
<p align="left">Finally, some styles must be added to fix the video player view on full-screen mode. These styles must also be taken into account when our React Native application has a top or bottom navigation bar, or both.</p>
<h2><b>Player preview with and without React Native Video landscape orientation</b></h2>
<h2><b><img decoding="async" loading="lazy" class="aligncenter wp-image-14178 size-medium" src="https://www.asapdevelopers.com/wp-content/uploads/2021/01/preview-300x184.png" alt="react native video example" width="300" height="184" srcset="https://www.asapdevelopers.com/wp-content/uploads/2021/01/preview-300x184.png 300w, https://www.asapdevelopers.com/wp-content/uploads/2021/01/preview-1024x629.png 1024w, https://www.asapdevelopers.com/wp-content/uploads/2021/01/preview-768x472.png 768w, https://www.asapdevelopers.com/wp-content/uploads/2021/01/preview.png 1411w" sizes="(max-width: 300px) 100vw, 300px" /></b></h2>
<h2><b>Bonus: lock your React Native Video orientation on portrait mode</b></h2>
<p align="left">Sometimes, you may want to keep your application from being used in landscape mode. This can be easily done by taking advantage of the ‘<b>React Native Orientation Locker’ </b>library we installed before.</p>
<p align="left">In iOS, however, the best way of doing this is with Xcode, so we will see both alternatives.</p>
<h2 class="western"><b>Portrait mode for Android devices</b></h2>
<p align="left">On the <b>App.js</b> file, you need to import the <b>React Native Orientation Locker </b>library and then import the following line of code:</p>
<ul>
<li>
<p align="left">Orientation.lockToPortrait();</p>
</li>
</ul>
<p align="left">That’s it, the file should look something like this:</p>
<p><script src="https://gist.github.com/joaquin-viera/0b0a1e15022950ce6f48e265e28c65b0.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/0b0a1e15022950ce6f48e265e28c65b0"><span style="font-weight: 400;">App.js</span></a></p>
<h2 class="western"><b>Portrait mode for iOS devices</b></h2>
<p align="left">You don’t need to install anything to do this, just follow these steps:</p>
<ul>
<li>
<p align="left">Open the project on Xcode</p>
</li>
<li>
<p align="left">Go to the project’s main folder</p>
</li>
<li>
<p align="left">Go to ‘general’</p>
</li>
<li>
<p align="left">Under ‘Deployment Info’ leave ‘Portrait’ checked</p>
</li>
</ul>
<p align="left">Run the application again from Xcode and the changes should be added.</p>
<h2><b>Final thoughts on React Native Landscape</b></h2>
<p align="left">Adding a landscape orientation to your video player drawer is simple thanks to the <b>React Native Orientation Locker </b>library. With this library, you can also set your entire project application to portrait mode or get full control over when you want something to be seen in landscape orientation.</p>
<p align="left">
		<div id="fws_693977483d0a7"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/react-native-san-francisco/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>React Native App Development Company</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/react-native-video-with-landscape-orientation/">React native ‌orientation‌ locker and ‌landscape‌ orientation</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>React Native Video &#038; Media Controls example</title>
		<link>https://www.asapdevelopers.com/react-native-video-media-controls-example/</link>
		
		<dc:creator><![CDATA[Joaquin Viera]]></dc:creator>
		<pubDate>Mon, 09 Nov 2020 18:08:40 +0000</pubDate>
				<category><![CDATA[React Native]]></category>
		<guid isPermaLink="false">https://www.asapdevelopers.com/?p=13799</guid>

					<description><![CDATA[<p>Nowadays, mobile applications are sweeping the development market and, thanks to frameworks such as React Native, it is possible to develop native applications for the Android and iOS operating systems...</p>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/react-native-video-media-controls-example/">React Native Video &#038; Media Controls example</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="font-weight: 400;">Nowadays, mobile applications are sweeping the development market and, thanks to frameworks such as </span><a href="https://reactnative.dev/"><b>React Native</b></a><span style="font-weight: 400;">, it is possible to develop native applications for the Android and iOS operating systems simultaneously, such as react native video.</span></p>
<p><span style="font-weight: 400;">Although every application has its particular purpose, there are certain features that are shared by most, such as navigation bars, user profiles, logins, and the feature we’ll be looking at in this post: </span><b>video players</b><span style="font-weight: 400;">.</span></p>
<p><img decoding="async" loading="lazy" class="aligncenter wp-image-13824 size-medium" src="https://www.asapdevelopers.com/wp-content/uploads/2020/11/react-native-video-image-300x255.png" alt="react native video player - image" width="300" height="255" srcset="https://www.asapdevelopers.com/wp-content/uploads/2020/11/react-native-video-image-300x255.png 300w, https://www.asapdevelopers.com/wp-content/uploads/2020/11/react-native-video-image.png 666w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<h2><b>Let’s kick things off</b></h2>
<p><span style="font-weight: 400;">Including an integrated video player in your application doesn’t sound so difficult when you can use third-party libraries on React Native applications. In this case, we will use </span><b>react-native-video</b><span style="font-weight: 400;"> and </span><b>react-native-media-controls</b><span style="font-weight: 400;">; this last one has another library dependency that you have to install, which is </span><a href="https://github.com/jeanregisser/react-native-slider"><b>react-native-slider</b></a><span style="font-weight: 400;">.</span></p>
<p><span style="font-weight: 400;">To install all these libraries, run the three following scripts on your terminal:</span></p>
<ul>
<li><b><span style="font-weight: 400;">npm install react-native-video </span>OR<span style="font-weight: 400;"> yarn add react-native-video</span></b></li>
</ul>
<ul>
<li><span style="font-weight: 400;">npm install react-native-media-controls </span>OR<span style="font-weight: 400;"> yarn add react-native-media-controls</span></li>
</ul>
<ul>
<li>npm install react-native-slider <b>OR</b><span style="font-weight: 400;"> yarn add react-native-slider</span></li>
</ul>
<h2><img decoding="async" loading="lazy" class="wp-image-13825 alignleft" src="https://www.asapdevelopers.com/wp-content/uploads/2020/11/react-native-video-code.png" alt="react native video - code image" width="110" height="95" /></h2>
<h2><b>Let’s jump into the code of React Native Video</b></h2>
<p><span style="font-weight: 400;">First of all, you need to have created a React Native project (for example, using </span><a href="https://reactnative.dev/docs/0.60/getting-started"><b>npx react-native init</b></a><span style="font-weight: 400;">).</span></p>
<p>&nbsp;</p>
<p><span style="font-weight: 400;">If you don&#8217;t know how to create your app, just run the following commands on your terminal:</span></p>
<p><script src="https://gist.github.com/joaquin-viera/6438adb3bf39d0f5724ab4e9e8344a85.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/6438adb3bf39d0f5724ab4e9e8344a85"><span style="font-weight: 400;">script</span></a></p>
<p><span style="font-weight: 400;">Now that you’ve created the application, let’s get to coding!</span></p>
<p><b>Important note: </b><span style="font-weight: 400;">this example was created with React Native 63.3 and it uses hooks and functional components.</span></p>
<p><span style="font-weight: 400;">First, check your package.json file to make sure the three libraries mentioned before are installed.</span></p>
<p><span style="font-weight: 400;">It should contain the following three lines (keep in mind that the libraries’ versions can change in the future). </span></p>
<p><script src="https://gist.github.com/joaquin-viera/b8a6fff8820086c96af455f08f4f8d6a.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/b8a6fff8820086c96af455f08f4f8d6a"><span style="font-weight: 400;">script</span></a></p>
<p><span style="font-weight: 400;">Next, create a custom component to define your video player.</span></p>
<p><script src="https://gist.github.com/joaquin-viera/f63ff69f5472bb2f8da59b833ef0304b.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/f63ff69f5472bb2f8da59b833ef0304b"><span style="font-weight: 400;">script</span></a></p>
<p><span style="font-weight: 400;">This is a small component, but it includes many functions and some hooks: </span></p>
<p><span style="font-weight: 400;">The useRef hook is used to get the video’s current timing and change it to throw the player bar. </span><span style="font-weight: 400;">The useState hooks are created to handle the video duration, whether the video is paused or not, the current video time, whether the player is PLAYING/PAUSED/ENDED and whether the video is loading.</span></p>
<p><span style="font-weight: 400;">You’ll also need some functions which are necessary to set both libraries’ props.</span></p>
<p><span style="font-weight: 400;">The functions needed for </span><b>MediaControls </b><span style="font-weight: 400;">are:</span></p>
<ul>
<li style="font-weight: 400;"><b>onSeek</b><span style="font-weight: 400;">: triggered when the user releases the player slider.</span></li>
<li style="font-weight: 400;"><b>onSeeking</b><span style="font-weight: 400;">: triggered when the user interacts with the player slider.</span></li>
<li style="font-weight: 400;"><b>onPaused</b><span style="font-weight: 400;">: triggered when the play/pause button is pressed.</span></li>
<li style="font-weight: 400;"><b>onReplay</b><span style="font-weight: 400;">: triggered when the replay button is pressed.</span></li>
</ul>
<p><span style="font-weight: 400;">There is a small bug on Android devices that does not allow the player to replay the video when changing the state to PLAYING, so you have to use the &#8216;Platform&#8217; API to fix that.</span></p>
<p><span style="font-weight: 400;">And the ones needed for </span><b>Video </b><span style="font-weight: 400;">are:</span></p>
<ul>
<li style="font-weight: 400;"><b>onProgress</b><span style="font-weight: 400;">: triggered while the video is playing.</span></li>
<li style="font-weight: 400;"><b>onLoad &amp; onLoadStart</b><span style="font-weight: 400;">: these allow you to do something while the video is loading. For example, you could set a preview image while this is happening.</span></li>
<li style="font-weight: 400;"><b>onEnd</b><span style="font-weight: 400;">: triggered when the player reaches the end of the media file.</span></li>
</ul>
<p><span style="font-weight: 400;">Here you can check more details about </span><a href="https://github.com/charliesbot/react-native-media-controls"><span style="font-weight: 400;">MediaControls</span></a><span style="font-weight: 400;"> and </span><span style="font-weight: 400;">Video</span><span style="font-weight: 400;"> props, and customize the video player even more.</span></p>
<p><b>Important note: </b><span style="font-weight: 400;">both Video and Media Controls components must be enclosed in the same component one followed by the other, in this case, in a View component.</span></p>
<p><span style="font-weight: 400;">And that&#8217;s it! As you can see, you don’t need many CSS styles to make it look good. The most difficult part is setting up all the components’ props to make the player work the way you want it to.</span></p>
<p><span style="font-weight: 400;">The final step is mounting your custom component in the App.js file to see how it works.</span></p>
<p><script src="https://gist.github.com/joaquin-viera/4f677a82db7160ccf89ba6a3e4235c0c.js"></script><br />
<b>Link:</b> <a href="https://gist.github.com/joaquin-viera/4f677a82db7160ccf89ba6a3e4235c0c"><span style="font-weight: 400;">script</span></a></p>
<h2><b>Player preview</b></h2>
<p><video preload="metadata" controls="controls" width="627" height="627"><source type="video/mp4" src="https://www.asapdevelopers.com/wp-content/uploads/2020/11/Demo-mp4.mp4" /></video></p>
<h2><img decoding="async" loading="lazy" class="wp-image-13828 aligncenter" src="https://www.asapdevelopers.com/wp-content/uploads/2020/11/Demo-image-300x262.png" alt="video player" width="624" height="545" srcset="https://www.asapdevelopers.com/wp-content/uploads/2020/11/Demo-image-300x262.png 300w, https://www.asapdevelopers.com/wp-content/uploads/2020/11/Demo-image.png 660w" sizes="(max-width: 624px) 100vw, 624px" /></h2>
<h2><b>Final thoughts on React Native Video &amp; Media Controls:</b></h2>
<p><span style="font-weight: 400;">As we’ve seen before with third-party libraries, it’s not difficult to add a video player to your React Native application. This article was written to show an easy way to add one to your projects. </span></p>
<h2>Asap developers</h2>
<p>asap has been developing web and mobile applications for <a href="https://www.asapdevelopers.com/web-mobile-app-san-francisco/">San Francisco Bay Area companies</a> since 2008. With a team of almost 30 hard-working members, we’re big enough to tackle almost any project and, at the same time, agile enough to respond to the changing needs of our clients. We see our clients as strategic partners, so we offer a comprehensive service that is completely focused on their success.</p>
<div id="fws_693977483e36f"  data-column-margin="default" data-midnight="dark"  data-bg-mobile-hidden="" class="wpb_row vc_row-fluid vc_row standard_section "  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-overlay="false"><div class="inner-wrap"><div class="row-bg"  style=""></div></div><div class="row-bg-overlay" ></div></div><div class="col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding"  data-t-w-inherits="default" data-border-radius="none" data-shadow="none" data-border-animation="" data-border-animation-delay="" data-border-width="none" data-border-style="solid" data-border-color="" data-bg-cover="" data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-hover-bg="" data-hover-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" ><div class="column-bg-overlay-wrap" data-bg-animation="none"><div class="column-bg-overlay"></div></div>
			<div class="wpb_wrapper">
				<a class="nectar-button large regular accent-color has-icon  wpb_animate_when_almost_visible wpb_bounce bounce regular-button"  style="margin-top: 40px; color: #ffffff; "  href="https://www.asapdevelopers.com/react-native-san-francisco/" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>React Native Development Company</span><i style="color: #ffffff;"  class="icon-button-arrow"></i></a>
			</div> 
		</div>
	</div> 
</div></div>
<p>The post <a rel="nofollow" href="https://www.asapdevelopers.com/react-native-video-media-controls-example/">React Native Video &#038; Media Controls example</a> appeared first on <a rel="nofollow" href="https://www.asapdevelopers.com">asap developers</a>.</p>
]]></content:encoded>
					
		
		<enclosure url="https://www.asapdevelopers.com/wp-content/uploads/2020/11/Demo-mp4.mp4" length="0" type="video/mp4" />

			</item>
	</channel>
</rss>
