Xamarin + VS RC 2017

I lose a challange , i delayed two project and ‘i lost my girlfriend before one day of the saint-valentin ‘  so let begin , these day i faced a big problem with Xmarin +VS RC 2017(February 7, 2017) when i create new Xamarin project and choose masterdetail template , i reported it at VS Developer Community and it’s marked as triaged.

The problem ?

When you build your android project , you get more than 3000 errors,
see picture bellow :

Solution !

You don’t belive if i say that one line can remove all these errors and let your project work succesfuly,

  1. Unload your Android project(right click on project>Unload Project)
  2. Edit Project (right click>Edit blabla.csproj)
  3. Search for this part

<Reference Include=”System” />
<Reference Include=”System.Xml” />
<Reference Include=”System.Core” />
<Reference Include=”Mono.Android” />
<Reference Include=”System.Net.Http” />

and add this reference ,

 <Reference Include=”mscorlib” />

  1. Save it , and reload the project 🙂

 

The Second problem

it’s related to UWP project when you create it ,

it show you

 

Package Installation Error

Could not add all required packages to the project. The following packages failed to install from 'C:\Program Files (x86)\MicrosoftSDKs\NETCoreSDK':

Microsoft.NETCore.UniversalWindowsPlatform.5.0.0 :Package restore failed .....

Solution

is very easy , open the Package Manager Console and type : “Install-Package Microsoft.NETCore.UniversalWindowsPlatform”

Re-Build it 😀

Facebook Live API: How to stream on Facebook

On 12 april  Facebook announced the ability to stream live video on Facebook Live from a drone. The company has already conducted a demonstration with a Phantom drone DJI. The news does not stop there because the Facebook Live API is now public.

live-api

I am happy to show you  how to start your first live stream via API.

In this tuto i will explain to two method to start your live via your own facebook app or i will provide link for a ready app that you can use it.

UPDATE 27-04-2016 :

Let your Facebook app ready to post 

After you create your Facebook applications (you can google it , is easy to do) and get you app-id.here’s a sample code that you need just to upload in a .html file to your server. Your only need your to change “YOURAPPIDHERE” with your APP ID that you get it from Facebook.

<html>
<head>
</head>
<body>
<script>
//Connect to the app via the facebook sdk 2.6
window.fbAsyncInit = function() {
FB.init({
appId     : 'YOURAPPIDHERE',
xfbml     : true,
version   : 'v2.6'
});
};
 
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/de_DE/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
 
<button id="liveButton">Live API activator</button>
<script>
document.getElementById('liveButton').onclick = function() {
FB.ui({
display: 'popup',
method: 'live_broadcast',
phase: 'create',
}, function(response) {
if (!response.id) {
alert('dialog canceled');
return;
}
alert('stream url:' + response.secure_stream_url);
FB.ui({
display: 'popup',
method: 'live_broadcast',
phase: 'publish',
broadcast_data: response,
}, function(response) {
alert("video status: \n" + response.status);
});
});
};
</script>
</body>
</html>

Use a ready app

As i say , here is a link   http://houssem.dbira.tn/testlive.html  i created in my website that you can use it to test the Facebook live api you will find the same when you follow the steps above.

When test the code or enter the link that i provide you will find a sample button ,buttonThe magic happens when you click. A long-known Share dialog appears and you can choose where the Live Stream to appear. Your own timeline, the timeline of a friend, a group or your pages.

post

After you choose and click next you will get a page which now gives you the stream URL and the Key .It looks like a normal video share post,  But what stands out are the two fields where actually had the video: Server URL and Stream Key.postfb-live

The server URL is always the same: rtmp://rtmp-api.facebook.com:80/rtmp, in general is the same and don’t change .
The key is something special. This key is valid only once and you can used it after generating only for 24 hours and for one single post Anyone who knows this key can go live and post in your place.
That was it! Well so half. Now, Facebook has delivered you everything need to stream it.

Preparation of the Stream Software.

I spend two day in searching the best software to stream, There are many tools that support RTMP streaming but most of them is paid. I want to show you one that i think is the excellent free version – “Open Broadcaster Software”. You can download it from here https://obsproject.com/download be sure to chose the studio version.

let us start the goals of this post,

After the tool is installed, you go to Settings and choose Stream.

obs1

select the Custom server option and there are exactly the fields that you receiveed from Facebook. fill data and press OK.

obs2

Now you can choose the source of media from camera ,video or picture ! let’s add some text or no you want a screen capture !? is the best right haha ! just play around a bit with the options i let this missions to you.

text2text1

text3

Now you can start the live stream . Do not worry, he is not yet published on Facebook. Look back now to posting window. MAGIC !!!! the preview of your stream and the “Go Live” button is clickable. Select it and your stream is live!

qq

Finally, a few specs for the stream:

720p at 30 frames / s
1 keyframe every 2 seconds
The bit rate should not exceed 2500Kbps
The video length is limited to 90 minutes
Thats it! …

… But that’s just the Quicky “How do I Live”. The API has many more great features. Just check out the rest in Facebook Live API documentation.

Don’t hesitate to comment below if you have any questions/problems 🙂