Unity Video Player Explained Fully | Learn Unity Mir Imad Ahmed

By | Programming, Unity | No Comments

Unity Video Player Explained Fully

unity video player

unity video player

New unity video player component has been introduced lately from Unity. I have had a chance to play around with the component in my applications.

I wrote about using video player with Vuforia AR here.

I am going explain as much as I can. Here is how it looks like:

unity video player component

unity video player component

I will try to explain things one by one.

Source

  • Video Clip – It can be a video clip imported inside unity project.
  • URL – You can play a video directly from a URL be it served over web or file:// protocols.

Play On Awake

If you keep this checked unity video player will automatically play your video as soon as you run the project.

Wait For First Frame

If you keep this checked unity video player will wait till it gets the first frame of the video loaded into the memory.

Loop

Self explanatory, helps you if you want to loop your video and want it to play itself again when it ends.

Playback Speed

It helps you speed up or down your video speed.

Render Mode

It requires more than just one line explanation. It has 5 different rendering modes as shown:

unity video player render modes

unity video player render modes

Camera Far Plane

Render the video on the Camera’s far plane.

Camera Near Plane.

Render the video on the Camera’s near plane.

Render Texture

Render the video into a Render Texture.

Material Override

Render the video into a selected Texture property of a GameObject through its Renderer’s Material.

API Only

Render the video into the VideoPlayer.texture Scripting API property. You must use scripting to assign the Texture to its intended destination.

Aspect Ratio

The aspect ratio of the images that fill the Camera Near Plane, Camera Far Plane or Render Texture when the corresponding Render Mode is used.

Following are the aspect ratio options we have:

No Scaling

No scaling is used. The video is centered on the destination rectangle.

Fit Vertically

Scale the source to fit the destination rectangle vertically, cropping the left and right sides or leaving black areas on each side if necessary. The source aspect ratio is preserved.

Fit Horizontally

Scale the source to fit the destination rectangle horizontally, cropping the top and bottom regions or leaving black areas above and below if needed. The source aspect ratio is preserved.

Fit Inside

Scale the source to fit the destination rectangle without having to crop. Leaves black areas on the left and right or above and below as needed. The source aspect ratio is preserved.

Fit Outside

Scale the source to fit the destination rectangle without leaving black areas on the left and right or above and below, cropping as required. The source aspect ratio is preserved.

Stretch

Scale both horizontally or vertically to fit the destination rectangle. The source aspect ratio is not preserved.

Audio

Then comes another crucial part of how you want your video’s audio to be considered. Do you want no audio, play directly on the hardware or do you want to do audio tweaking as well. For that you will have to select Audio Source option.

If you select Audio source as the option you will have to provide the reference of the audio source component where you want the audio to be played through. Then in that audio source component you can do the tweaking.

Watch my All unity tutorials.

Learn how to unity play video on canvas in unity. 

validate domain ionic

Validate Domain Ionic 3 or 2 | Learn Form Validation in Ionic Part 1

By | Ionic, Programming

Validate Domain Ionic 3 or 2 | Learn Form Validation in Ionic Part 1

validate domain ionic

validate domain ionic

this.domainForm = FormGroup;
  this.domainForm = fb.group 
  ({
    'domain':[null, Validators.compose([Validators.required, Validators.pattern(/\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/)])]
  })

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <form [formGroup]="domainForm">
    <ion-item>
      <ion-input type="text" name="domain" placeholder="start typing" [formControl]="domainForm.controls['domain']">
      </ion-input>
    </ion-item>
    <button ion-button full block [disabled]="!domainForm.valid">Search Domain</button>
  </form>
</ion-content>

 

Need help to understand more?

Watch the video:

Thanks for reading.

Latest post: Learn to download asset bundle from server in unity

Created a mobile app for domain research. Its V0.1 for now so expect a simple and basic design.

I am open for your comments and suggestions on how can I improve the app.

iOS: https://goo.gl/5kzWFn

Android: https://goo.gl/3H3Zfj

#android #iosdevelopment #ionicframework #domainregistration #domainnames #hobbies

11 points from Imran Khan for a Prosperous Pakistan

By | Motivation

PTI is the largest party of Pakistan and fairly popular among the youth of Pakistan. PTI has educated people about rights and politics situation. On 29th April, 2018 Pakistan Tehreek Insaf held jalsa in Minar e Pakistan Lahore. In that jalsa Imran Khan presented his 11 points agenda for a prosperous Pakistan. These 11 points are as follows:

  1. Focus on education. Today more than 2 crore Pakistani kids are out of schools. Previous governments have not spent enough amount on education. Previous governments have not taken steps to open good schools, high standard educational institutes or international standard universities. We have to invest in our people instead of roads and bridges. We will bring one whole curriculum for the whole country. We will strengthen government schools.
  2. Focus on health. We will construct new hospitals for everyone. Poor people will not have to worry about the medication expenses. The amount Pakistani people spent on health by going outside from Pakistan we can setup a new cancer hospital each year from that amount.
  3. Previous governments have increased our loans to 27000 billion rupees. We will collect funds from these Pakistani people to get rid of our international loans. Our people are very generous, if you guarantee them that the money they give as tax or charity will not go into bogus politicians pockets they will give generously. We will bring reforms to the federal bureau of revenue to make our country strong. We will pay all our loans ourself.
  4. We will make our judiciary and accountability institutions strong by bringing reforms. We made a historical move by holding our 30 parliamentarians accountable. We started from our own party and now we will eliminate corruption from Pakistan. We will eliminate money laundering and bring back all the laundered money. All the recollected money will be spent on our children’s education.
  5. We will lower our taxes on electricity and gas so our industries grow. We will bring reforms so people can bring business and investment to our country. The overseas Pakistani will invest in Pakistan. We will bring ease in doing business in Pakistan.
  6. 5 million cheap homes will be constructed to re-establish the industries related will be honed and people will get more jobs.
  7. Tourism is the most profitable industry these days. I have decided to open 4 new tourist spots every year. Pakistan has a lot of breath taking areas. There are a lot of unattended places that are far more better than Switzerland. We will give special focus to tourism.
  8. Farmers have been financially destroyed in the past years. We will have an agricultural emergency to bring reforms to farming. We will construct research centers, universities and other reforms for farmers so they can earn more and have a prosperous life.
  9. We will strengthen our federation. We will give equal rights to all of our provinces. We will have mayor system. We will bring reforms for southern Punjab province. We will also mix FATA to KPK province. I promise people of FATA that once we come in federal government we will develop FATA and give you representation in KPK assembly.
  10. We will give special attention to environmental side. All other provinces have not done anything for water, air pollution, forests, etc. We will make all our areas environmentally clean.
  11. As we have brought reforms to KPK police department, we will bring reforms to the police department of all other provinces and make them depoliticize. One day will come people will praise the police of Punjab as they do in KPK.
5 rules of success

5 lessons for success I learned from Qasim Ali Shah.

By | Motivation | No Comments

5 lessons for success I learned from Qasim Ali Shah.

1. Always give out from what you have. Make your mission to give away something from what you earn. May it be money, knowledge or respect. Give others what you want more. The more you give the more you get.

2. Confident people always get ahead of anyone else. Always have confidence on yourself. Teachers must motivate the students instead just making them learn by heart. Confident people always get ahead of intelligent people.

3. Make your connection strong with your creator. The strong your connection is with your GOD the more determined and strong your believe in self will be.

4.  Discover yourself and once you know your purpose work hard to become the best in your field. Stay focused and love your field. Become the best you can be in your own field.

5. Always have people who pray for you. Get good wishes from your parents as a known saying “Maa ki dua Jannat ki hawa” – “Mom’s good wish for you can take you to heaven”. People with good luck can take numbers from those who are intelligent.

Learn How To Download Asset Bundle From Server in Unity 3D | Under 2 Minutes

By | Programming, Unity | No Comments

Hello Everyone !!

I have been receiving a lot of requests to make a tutorial on how to download asset bundle from server in Unity 3D. Here I made a simple video tutorial for you guys to learn how you can download asset bundle from server under 2 minutes.

Asset bundles are a great way to maintain and expand your game. In this video I show you how to set up asset bundles and use them in an online Unity game or application. I have also written about making and exporting asset bundles here.

Downloading asset bundle from server is as easy as shown. In under 2 minutes you will see how I downloaded asset bundles from server using simple Unity 3D and C# code.

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
 
public class MyBehaviour : MonoBehaviour {
    void Start() {
        StartCoroutine(GetAssetBundle());
    }
 
    IEnumerator GetAssetBundle() {
        UnityWebRequest www = UnityWebRequest.GetAssetBundle("http://www.my-server.com/myData.unity3d");
        yield return www.SendWebRequest();
 
        if(www.isNetworkError || www.isHttpError) {
            Debug.Log(www.error);
        }
        else {
            AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
        }
    }
}

 

Watch my All unity tutorials.

Learn about unity video player. 

 

Project Euler Problem 10 Solution

Project Euler Problem 10 Solution in C#

By | Programming, Project Euler | No Comments

Do you need “Project Euler Problem 10 Solution c sharp” . We will discuss all the problems in Project Euler and try to solve them using Python or C#. I have solved Project Euler Problem 9 C Sharp as well.

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

So we have to solve this problem using C#.

Lets first of all open Visual Code.

If we analyze the problem statement given here, we can see that we are asked to find the sum of all the prime numbers below two million.

Project Euler Problem 10 Solution C Sharp 

Lets start! 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            double sum = 0;
            int count = 2;
            while(count < 2000000){
                if(isPrime(count))
                    sum += count;
                count++;
            }
            
            Console.WriteLine(sum);
            
        }
        
        static bool isPrime(int a){
            for(int i = 2; i<=Math.Sqrt(a); i++) 
                if (a % i == 0) 
                    return false;
            return true;
        }
    }
}

 

For such type of problems the first thing that hit my mind was Brute Force! Obviously!

I put a while loop from 2 (because two is the smallest prime number;) ) till count < 2 Million.

Then I made a special function to return a boolean by checking the mere condition of isPrime.

I checked for each element by brute force and got my answer right there and then.

Yaay! We got this right. Thanks for reading.

Happy coding!

Project Euler Problem 9

Project Euler Problem 9 Solution in C#

By | Programming, Project Euler | No Comments

Do you need “Project Euler Problem 9 Solution c sharp” . We will discuss all the problems in Project Euler and try to solve them using Python or C#. I have solved Project Euler Problem 8 JS as well.

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,

a^2 + b^2 = c^2
For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

So we have to solve this problem using C#.

Lets first of all open Visual Code.

If we analyze the problem statement given here, we can see that we are asked to find the pythagorean py triplet number.

Project Euler Problem 9 Solution C Sharp| 

Lets start! 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //Your code goes here
            Console.WriteLine("Hello, world!");
            for(int a = 1; a < 998; a++)
                for (int b = a + 1; b < 998; b++)
                    for( int c = b + 1; c < 998; c++)
                        if (isPyTriple(a,b,c))
                            if(a + b + c == 1000)
                            {
                                Console.WriteLine(a);
                                Console.WriteLine(b);
                                Console.WriteLine(c);
                                Console.WriteLine(a*b*c);
                            }
            
            
            
            
        }
        
        static bool isPyTriple(int a, int b,int c){
            return (a * a) + (b * b) == (c * c);
        }
    }
}

For such type of problems the first thing that hit my mind was Brute Force! Obviously!

I put a for loop inside a for loop which is also inside a for loop so that we can brute force the three numbers a, b and c.

Then I made a special function to return a boolean by checking the mere condition of PyTriplet.

I checked for each element by brute force and got my answer right there and then.

Yaay! We got this right. Thanks for reading.

Project Euler Problem 10 Solution C#

Happy coding!

become digital nomad

5 Reasons to become a digital nomad?

By | Online Earning | No Comments

Many individuals are just born creative and talented. They usually have a great desire to exhibit skills in some form. I was the same who always wanted to experiment with what I learn and apply it to my daily life somehow. I started freelancing out of curiosity when I was in COMSATS Institute of Information Technology doing my Bachelors of Science in Software Engineering. Now when I am already graduate and in my professional life. I always support the idea to become digital nomad.

There are many freelancing websites but Toptal is the one that stands out the most. Here are my top 5 reasons to become digital nomad using Toptal web developer Network.

1. Satisfy my creative impulse

Freelancing itself is very challenging as you get to deal with a lot of clients from across the globe. Your creative juices come in to play when you have to build solutions for different clients as they get crazy with their requirements. Toptal offers you to work with some of the top companies around the world. Which means you are going to put great use of your creativity in solving problems for the world.

2. Travel freely while you work

Since you are working remotely, you can easily travel to anywhere you want. To be able to live a life of unlimited travel – that’s a dream you can turn into a reality when you become a digital nomad. Creating a lifestyle and a business that you can take with you and work on, from anywhere in the world, will allow you to travel and see more of the world than you’ve ever dared to dream of before.

3. Choose your own Schedule

Those who have worked in the office know how hard it is for them to get their days-off approved from the bosses. It’s different for freelancers. Provided that you have completed your project, simply don’t accept any new assignment for a self-imposed break from work. Pack your bags and slip to your favorite destination with your family or friends. Work in day or night whatever time you like. This is one of the most fantasizing benefit of why you become digital nomad.

4. Minimalism

Minimalism does not mean wearing the same dirty jeans, and not washing your hair for months on end. Minimalism represents getting your house in order. You can easily priorities things and get your things straight. You can keep things simple because you are always on the go.

5. Mouth Watering Portfolio

When you work online and for clients/companies from every corner of the world your experience and portfolio grows to a very mouth watering extent. All kind of fancy projects you create while solving problems for big companies around the globe your worth increases day by day.

Project Euler Problem 8

Project Euler Problem 8 Solution in JS

By | Programming, Project Euler | No Comments

Do you need “Project Euler Problem 8 Solution JS” . We will discuss all the problems in Project Euler and try to solve them using Python or JS. I have solved Project Euler Problem 6 Python as well.

The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.

7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450

Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?

So we have to solve this problem using JS.

Lets first of all open Visual Code.

If we analyze the problem statement given here, we can see that we are asked to find the largest product of the thirteen adjacent digits in the above given numbers.

Project Euler Problem 8 Solution JS | 

Lets start! 

var a = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450";

var index = 0;
var max = 0;

while(index!=988)
{
    var temp = parseInt(a[index]) * parseInt(a[index+1]) * parseInt(a[index+2]) * parseInt(a[index+3]) * parseInt(a[index+4]) * parseInt(a[index+5]) * parseInt(a[index+6]) * parseInt(a[index+7]) * parseInt(a[index+8]) * parseInt(a[index+9]) * parseInt(a[index+10]) * parseInt(a[index+11]) * parseInt(a[index+12]) ;
    
   	if(temp > max)
    {
    	max = temp;    
    }
    index++;
}


print(max);

We put the big giant number into a string variable. Now lets traverse the string element one by one. Take 13 numbers at one time by adding offset to the current index. Take the loop until we get the last 13 numbers.

Convert the each element after adding the offset into integer because initially it was in string. Now lets multiple all the elements and compare it with a max variable.

We need to update max variable in case if our product is larger then max.

Project Euler Problem 8 Solution JS

Yaay! We got this right. Thanks for reading.

Happy coding!

Project Euler Problem 7

Project Euler Problem 7 Solution in C#

By | Programming, Project Euler | No Comments

Do you need “Project Euler Problem 7 Solution C#” . We will discuss all the problems in Project Euler and try to solve them using Python or C#. I have solved Project Euler Problem 6 Python as well.

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

So we have to solve this problem using C#.

Lets first of all open Visual Studio.

If we analyze the problem statement given here, we can see that we are asked to find 10001st Prime Number

Project Euler Problem 7 Solution C# | 

Lets start! 

The first thought came across my mind is Brute Force!

Yes right. So lets create a while loop taking number one plus each time and checking for prime number. If the number is prime just update a counter. And upon reaching 10001th prime number we stop and print the prime number.

A prime number is that dont get divided by 1 or itself. If it gets fully divided by 1 or itself then it is not a prime number.

For big numbers we can use this mathematics rule that if the number does not divide upto its square root then it will never

//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int count = 0;
            int num = 2;
            while(true){
                if(isPrime(num)) count++;
                if(count == 10001) break;
                num++;
            }
            Console.WriteLine(num);
            //Your code goes here
            Console.WriteLine("Hello, world!");
        }
        
        static bool isPrime(int num){
            for (int i = 2; i < num; i++){
                if(num % i == 0) return false;
            }
            return true;
        }
    }
}

Lets see if we got it right.

Project Euler Problem 7 Solution c#

Project Euler Problem 7 Solution c#

Yaay! We got this right. Thanks for reading.

project euler problem 8 solution javascript

Happy coding!