Tag Archives: mirror

Stream You Tube Video, in Google Glass Time Line Card, using Mirror API(C#.net)

Ok guys today we will see how we can stream a Youtube video inside a google glass timeline card.  First you need to add reference to the “YoutubeExtractor” namespace. You can get it from the nuget if you dont have it.

using YoutubeExtractor;

Now add the youtube video url to atring(The url you got when you clicked the share button not the page url).
Resolve the url and get the links for the available videos.
Select the video you wanted to stream and get the stream url.

string link = "http://youtu.be/9uYKISlL7Vg";
IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);
VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);
String vLink = video.DownloadUrl;

Now create the timeline card and add the menu item

TimelineItem yotubeVideo = new TimelineItem()
{
Text = "Youtube Video",
BundleId = "8081",
MenuItems = new List<MenuItem>() { { new MenuItem() { Action = "DELETE" } } },
Notification = new NotificationConfig() { Level = "DEFAULT" }
};

Create a stream using the link we got, create a http request, buffer it and insert the card mentionng the video type.

String videoLink = vLink;

if (!String.IsNullOrEmpty(videoLink))
{
Stream stream = null;
if (videoLink.StartsWith("/"))
{
stream = new StreamReader(controller.Server.MapPath(videoLink)).BaseStream;
}
else
{
HttpWebRequest request = WebRequest.Create(videoLink) as HttpWebRequest;

request.UseDefaultCredentials = false;

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

byte[] b = null;
using (Stream streamFromWeb = response.GetResponseStream())
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
do
{
byte[] buf = new byte[1024];
count = streamFromWeb.Read(buf, 0, 1024);
ms.Write(buf, 0, count);
} while (streamFromWeb.CanRead && count > 0);
b = ms.ToArray();

stream = new MemoryStream(b);
}
}
controller.Service.Timeline.Insert(yotubeVideo, stream, "video/mp4").Upload();

Now the stream will work like a charm

Advertisements

Adding a time line card using Mirror API, that can make call from Google Glass (C#.net)

To call a person you need contact details of a person so we will create a contact first.

Contact Amalan = new Contact();
Amalan.PhoneNumber = "+940711111111";

Now create a Timeline card and add call function on the menu item of the  card. When create the timeline card add the contact we created as the Creator

TimelineItem contactNumber = new TimelineItem()
{

Text = "Call Amalan",
BundleId = "8081",
Creator = Amalan,
MenuItems = new List<MenuItem>() {
new MenuItem() {Action = "VOICE_CALL"},
new MenuItem() {Action = "DELETE"}},
Notification = new NotificationConfig() { Level = "DEFAULT" },

};

Now we will insert the card that we created

controller.Service.Timeline.Insert(contactNumber).Fetch();

That’s it now you can make the call using the timeline card. Don’t forget to pair your phone with the GLASS

Insert Video in, Google Glass Time Line Cards, using Mirror API(C#.net)

private static String InsertVideo(MainController controller)
{

TimelineItem critical = new TimelineItem()
{

//Text = "Third Card",
BundleId = "346",
//IsBundleCover=true,
//Html = "<article class=\"photo\">\n  <img src=\"http://www.youtube.com/watch?v=suz446-BOHg\" width=\"100%\" height=\"100%\">\n  <div class=\"photo-overlay\"/>\n  <section>\n    <p class=\"text-auto-size\">Third Card</p>\n  </section>\n</article>",
//Attachments = new List<Attachment>() {new Attachment(){ContentUrl="http://www.youtube.com/watch?v=suz446-BOHg"}},
//MenuItems = menu,
Notification = new NotificationConfig() { Level = "DEFAULT" },
MenuItems = new List<MenuItem>()
{
new MenuItem() {Action = "NAVIGATE"},
new MenuItem() {Action = "DELETE"},
new MenuItem() {Action = "SHARE"},
}
// Locaton = location.Latitude
//bundleId = 10001;
};

String mediaLink = "your video link as text here";

if (!String.IsNullOrEmpty(mediaLink))
{
Stream stream = null;
if (mediaLink.StartsWith("/"))
{
stream = new StreamReader(controller.Server.MapPath(mediaLink)).BaseStream;
}
else
{
HttpWebRequest request = WebRequest.Create(mediaLink) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

byte[] b = null;
using (Stream streamFromWeb = response.GetResponseStream())
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
do
{
byte[] buf = new byte[1024];
count = streamFromWeb.Read(buf, 0, 1024);
ms.Write(buf, 0, count);
} while (streamFromWeb.CanRead && count > 0);
b = ms.ToArray();

stream = new MemoryStream(b);
}
}
controller.Service.Timeline.Insert(critical, stream, "video/mp4").Upload();
}
else
{
controller.Service.Timeline.Insert(critical).Fetch();
//controller.Service.Timeline.Update

}

return "A timeline item has been inserted.";

}

Credit goes to Sanath Nandasiri

Google Glass and It’s Battery Consumption

Ok, developing apps and glassware for Google Glass seems to be not a big deal……!
But there are some hidden issues we have to take care of…!

GoogleGlass_1

1st one is Battery and the 2nd one is Performance…!

Even though the Google said the Battery will last for 1 Day, I could not experience the glass battery as long as that, unless it was left to sleep. When the Battery was full, I started taking a video, I got warning in 20 minutes saying battery is low, that’s it, I have to stop taking video and shutdown the glass. Here is the Video Taken.

So you must have understood, how poor the battery life is in Google Glass. So running a native Android is really a battery draining factor, specially pairing to phone through Bluetooth. And if you are using any sensors in the glass then that will cause heavy battery usage.

Alternatively we can do something like, keeping down the brightness of the display, and put the glass to sleep at most of the time(When app is idle). Avoid doing heavy process in the glass by sending the data to a server and process it and get the result.

I have read some people’s review say, using Glassware can solve the battery problem. Yes, as it is a plain html card which does not java script it won’t drain much battery.

But anyway the cards are shown in web browser objects. Smart phone users know the battery drain very much when they use web browser. So If the glassware results are going to be  shown in a series of web browser object which is called time line won’t it be draining battery very much? This point is just a conceptual thinking of mine.

Even though we have discussed only some facts about battery, there are more hidden battery factors too. But some leaked patent doc shows possible 2 side battery increasing the battery capacity by double.

One of my friends suggested a tip and it is using external battery w/USB
Here is the picture of it. You can try this too if you want more battery power. Further he mentioned that it lasts for the whole day. If you like follow him on twitter for more tips
BVfIq94IEAAZP3B.jpg large

That’s all for today, catch you guys soon with more on Google Glass…!

Google Glass Deep Inside(In Programers’ View )

Basically the Google Glass runs Android OS. It means if you know Android(or Java) you can easily write apps for the glass.

If you want a basic idea about what is google glass please read my previous post.

But there are some important stuffs you have to look into and research, before you jump into the app development. With limited hardware resources, the capability of the devices is restricted. At the time of writing this article the Explorer Edition 7 update is released and we can do some stuffs like, take a photo, record a video, start a hangout, send an email, browse web and some other stuffs.

The device is not like phone, where it does not have a touch display, the glass works by voice commands and mostly by tapping and scrolling the side of the glass. So you cannot expect to add buttons sliders. Still an SDK is not released to develop app for the glass.

If you have been wondering on what would it take for someone to get up and running with google glass development. Following is a list of technologies that forms the technology stack for google glass:

  • Web service protocol: REST
  • Message format: JSON
  • Google Mirror  API: Java, .NET, PHP, Python, javascript, Ruby

Well, we can start on with what Google Glassers have termed as “Glassware“. Glassware is a piece of software built on top of Google Mirror API. Google Mirror API is a set of Restful web services which help to communicate to and fro with google glass devices. Lets look at the diagram below to understand a little better.

GoogleGlass1

Above depicts interaction between google glass device and glasswares based on google mirror API.

What one can do using Google Mirror API?

  • Creating new cards on a timeline
  • Updating current cards on a timeline
  • Receiving user-initiated input exposed through a card’s menu
  • Subscribing to notifications from Glass devices to be notified of user actions

lets see the Google Glass – Mirror API – Glasswares – High Level Architecture

google-glass-high-level-architecture

Lets try and understand the above architecture:

  • Glass users subscription to your service: You develop one or more web-based service for google glass and publish. These services can be termed as glasswares. Glass users subscribes to your service by logging on to your website authenticating themselves using OAuth 2.0
glass camera
User subscription by visiting a glassware site
  • Glassware updates using Mirror API: Your google glassware then starts publishing to google glass cloud using mirror API. To be able to that, you must register your service with google cloud.
  • Google Glass synchronizes with glass device: This is third aspect. Once your glassware publishes to google cloud using mirror api, google glass then synchronizes your updates to your subscribed users.

You can control the glassware sites you have subscribed by logging in to MyGlass account . You can access this with the MyGlass Android App too.

final
User can On and Off Notifications to glass from this online site

In the above image you can see my glassware “Batman’s Layer” is listed with the other glasswares I have subscribed.

Ok then In my next post we will see what you needed to start developing for Google Glass …!

References: http://vitalflux.com/tag/google-glass-2/page/2/

What is a Google Glass

Google-Glass

Google Glass (styled “GLΛSS”) is a wearable computer with a head-mounted display (HMD) that is being developed by Google in the Project Glass research and development project, with the mission of producing a mass-market ubiquitous computer. The computer in the glass is running an Android OS (Android 4.0.4)Google Glass displays information in a web card format just like Google Now Cards , that can interact with the Internet via natural language voice commands, which are more advance than the current Voice to Text feature.Glass is being developed by Google x, which has worked on other futuristic technologies such as driverless cars. The project was announced on Google+ by Project Glass lead Babak Parviz, an electrical engineer who has also worked on putting displays into contact lenses; Steve Lee, a product manager and “geolocation specialist”; and Sebastian Thrun, who developed Udacity as well as worked on the self-driving car project.
Thad Starner, an augmented reality expert, is a technical lead/manager on the project.

The glass is mainly used to display information to the user. And not intended to handle heavy jobs like gaming. Because battery and the safety of the eye is most important aspect to care about.

glass camera

This kind of  a view will be displayed on the right hand top corner of the glass. This view is captured when the video record mode is active.

augmented reality computer

Some cross structure of the device and what it can do…!

This is how the Google Glass Menu look like?

ok_glass_menu

How to work with google glass menu?

All you have to do is say, “Ok Glass”. And you get the above shown command menu

How you go about selecting a particular menu item?

Now what you have to say is one of the following:

  • ok glass, google …
  • ok glass, take a picture
  • ok glass, record a video
  • ok glass, get directions to…
  • ok glass, start a hangout…
  • ok glass,send a message to…

With latest version more commands will be available[2]

Hardware

Camera

Google Glass has the ability to take photos and record 720p HD video. While video is recording, a recording light is displayed above the eye, which is unnoticeable to the wearer.

Touchpad

A man controls Google Glass using the touchpad built into the side of the device
The side of Google Glass is a touchpad, allowing users to control the device by swiping through a timeline-like interface displayed on the screen.
Technical specifications

For the developer Explorer units:

Android 4.0.4 and higher

No official information about display resolution, 640×360 suggested, as it is recommended for app developers

  •     5-megapixel camera, capable of 720p video recording
  •     Wi-Fi 802.911b/g    Bluetooth
  •     16GB storage (120 GB available)
  •     Texas Instruments OMAP 4430 SoC 1.2Ghz Dual(ARMv7)
  •     682MB RAM .
  •     3 axis gyroscope
  •     3 axis accelerometer
  •     3 axis Magnetometer (compass)
  •     Ambient Light sensing and Proximity sensor [1]

Lookout for the next post where Ill be writing about google glass on a programers view. With some Hands On Fun stuffs…!
😀

References
[1]http://deepakcristiano.blogspot.com/2013/05/what-is-google-glass.html
[2]http://vitalflux.com/tag/google-glass-2/page/2/