Add video to timeline from GDK or Add "Share" to live card - google-glass

I'm using the GDK with XE16
I would like to save a video using MediaRecorder and then put it on the Timeline so I can let the user share the video to Gplus, YouTube or any contact. I am providing some additional information during the recording process as an overlay on the video preview.
I am able to save the videos into the /mnt/sdcard/Movies path. I am invoking the Intent.ACTION_MEDIA_SCANNER_SCAN_FILE to add the recorded video to the media database.
I have not been able to figure out how to add a share intent to on livecard. The previous API supported static cards, but those did not support video attachments; and the API is no longer available. I have also tried to use AccountManager and the com.google account in Glass to get an ouath token for the Mirror api to write direction via oauth2:https://www.googleapis.com/auth/glass.timeline. The authorization request shows up, but it is impossible for the user to accept the request.
I've considered sending the video file back to a proxy server that will then call mirror, but this seems like a big round trip for nothing.
I suppose I could send the credentials through this proxy, but this seems like a security nightmare.

The difference between Static Cards and a Timeline Item were large enough that the team, apparently, removed Static Cards until they could make the two of them work much more similarly. What you're trying to do is a commonly requested, and it does make sense that both should work mostly the same way.
You're on the right track for how to handle this at the moment - use the Mirror API to get it into the timeline as a Timeline Item. As you've noticed, you can't go through the auth flow since the user is unable to authenticate through Glass directly.
While you're testing, you can code in an auth token and a refresh token to be provided to the library to do this. For production through MyGlass, take a look at the auth flow that is available at https://developers.google.com/glass/develop/gdk/authentication

Related

Notification for new photo/video upload in Google Photo API

I'm working on a digital photo frame app with the new Google Photo Library API beta.
Assume that multiple devices are able to access the same album (shared album, or login with the same account), when there is a picture uploaded from one device, can other devices receive any notification regarding the new upload? If polling is needed for now (that's not really something efficient), what's the recommended interval for polling?
The platforms are Android (TV+Mobile)/iOS/tvOS
Right now there's no way to be notified of any changes to the library or albums.
You will need to poll an album (ie. list its contents) or the library to see if any new media has been added. For albums you could also just list the albums and check if the number of media inside it has changed.
The polling interval depends on your use case and how long of a wait is acceptable to your users. For example, you could run a manual refresh in the background every hour if your app isn't open and refresh more frequently when the user is interacting with your app. Maybe you could also include a 'refresh' button to trigger it manually?
Alternatively, if the entire process is handled through your application, you could also send a notification through a different notification service (Firebase Cloud Messaging) to notify your apps and server that a new media item has been added. This is something you'd need to implement yourself though.
This is definitely something that has come up before and I'd encourage you to file a feature request on our public issue tracker: https://developers.google.com/photos/library/support/how-to-get-help#missing-features

NFC Photography Identification

There was a music event a friend of mine went to and they had a few photographers waling around out there. The photographers took photos that were instantly uploaded to the users facebook account via an NFC wristband. The workflow when it was explained to me looks like this:
Step-1 Get a nfc wristband at the Kiosk- Facebook will be encoded into the wristband.
Step-2 Walk around the event. If a photographer takes your picture, hold your wrist to the camera and the image will be watermarked with event/sponsor logos at the bottom and posted to your facebook account .
So, I was thinking how this could possibly be done- I googled and googled, but I got nothing. Here's my guess- All the FB authentication can be in the wristband. An EyeFi SD card has the ability to take a photo and transmit it. NFC Arduino reader could read the persons wristband, authenticate, then go into the images and pull the last photo that was taken and post it to the users fb page. What do you think?
We have a (beta) product that performs this exact function. It's called Flomio Kiosk. The way it works is with NFC wristbands and Android NFC terminals like the Galaxy S4 Zoom. The system lets guests associate wristbands/cards to their Facebook or Email accounts. The NFC Kiosk application has a photographer mode that allows pictures taken to be tagged and uploaded with the scanned wristband's profile.
The architecture of the stack is straightforward. The UUID of the wristbands are associated with the Facebook token of the associated guest. This needs to be stored in a cloud server so that you can effectively OAuth2.0 to Facebook and post on behalf of the guest. This setup also allows us to remain liability free of ill formed posts. Each developer that uses our system needs to create their own Facebook app and get it approved. If spam or content that violates Facebook T&C is posted then only that Facebook app will be shutdown rather than the whole Flomio Kiosk solution.
In order for us to grab the Facebook token for each guest, the guest must go to the events' landing page (we use eventname.flomio.com), enter their wristband code (5 digit number) and sign in with their Facebook credentials. The guest can then select what permissions to give the event application, such as post to "Only Me" and allow access to their "News Feed". Once this registration process is complete the wristband is considered activated and the OAuth token for accessing the guests Facebook profile is stored in the Flomio database alongside the wristband UUID.
When a wristband is scanned at an access point, the UUID is sent up to Flomio via websockets for ultra-fast responsiveness that reveals the guest name and profile picture. This way event organizers can provide a more personalized experience to guests. In photographer mode, the images are taken and then wristbands are scanned. Images are posted through Flomio where event logos are overlaid on the pictures for added brand recognition. Included are predefined post messages as well that event organizers can curate before hand. Here's a simple diagram of how things come together.
For high end cameras like the Nikon D300 we use the Transcend Wifi SDcards as they're more hacker friendly. These run Linux so we execute some scripts to tag the photos as soon as they're taken but upload them later through a background process. Our Kiosk solution is undergoing maintenance right now to add support for our FloJack and FloBLE product lines. Once complete any smartphone will be able to act as a scan terminal in a multitude of deployment scenarios. Sign up for our blog to stay tuned with our latest releases.

Navigate to the timeline (to the card with bundleId) from within an application

I have a Glass application that is activated by a voice command. The user requests a product and the request is then passed on to a node.js server, which handles the bulk logic of my application. When the node server is done, it builds some HTML templates that it passes on to the Mirror API, which then puts those cards into the timeline of the Glass app.
Now the problem I have is this:
When a user requests something from within the application, he just stays within that application but the cards from the Mirror API are put onto the timeline.
Is it possible to navigate the user from within the application to the timeline item that has just been inserted?
As I build the Mirror API timeline item, I know ahead of time what the bundleId will be on the timeline, so can I use that somehow to navigate to that item on the timeline?
I've had a look here on Stackoverflow, the Glass forums and the official documentation and couldn't see anything that would help.. Anybody here have any ideas?
Currently the only way for forcing a specific card to show in the timeline is by using a LiveCard (https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard). Live cards will automatically be given focus when published and you can force the timeline to give your card focus after publishing by calling LiveCard.navigate().
So unfortunately unless you want to change some of the fundamentals of your app, this isn't going to be much help.
Though from the sounds of it, you may be able to use a LiveCard to show what is returned from your server. If you want to perform inserts via the mirror API, this could still be done in addition.

How to add another option to the share functionality of Google Glass?

I am interested to add my service into the share functionality of the Google Glass, my flow is below:
1. Take photo / Record video
2. Share with -> My service
3. the photo or video should be uploaded to my site
Is this functionality possible? it is very similar to Facebook and G+ share options.
I will be happy to know how to do it, Thanks.
What you are looking for is what the Mirror API calls a Contact. Your Glassware can setup one or more Contacts, specifying what content type can be shared with you and/or if there are voice commands which will trigger the Contact.
You will also need to setup a Subscription which will be the public URL for an HTTPS enabled server that the Mirror API will use to send you the content that was shared with the Contact.
In general, the flow when a user first authorizes you to write to their time would be something like this:
Add a Subscription, so you can get callbacks.
Add one or more Contacts. In your example, you would want to register the Contacts to have acceptTypes of image/* and video/*, although you can also omit the acceptTypes to get everything (including text).
The callback you register with the subscription should be able to handle a JSON body, and should return HTTP code 200 as quickly as possible. A good procedure is to actually accept the body, place it on a job queue for processing later, and immediately return the 200 code. When processing the body, you may want to do something like
Confirm the userToken and verifyToken provided are valid.
Using the itemId, get the Timeline item, which will include attachment information about what was shared with you.
If the attachment is marked as isProcessingContent, then the content isn't ready for you and you should return the job to the queue and try again soon.
If isProcessingContent is false, you can use the attachment URL with the authentication token for the user to fetch the content itself.
There are a lot of details I've glossed over here. For a further overview of the flow, see https://developers.google.com/glass/develop/mirror/contacts

HTML5 Canvas to Facebook

I've made a basic HTML5/JS comic creation tool that uses the canvas element.
I want users to be able to upload their comics via the Facebook API.
I don't believe Facebook allows posting images in the form of base64 strings from the canvas.toDataURI() method, and don't want to use my own server to convert these images & temporarily store them.
What's the best way to go about this? Possibilities I've wondered about: Convert canvas to blob? Store blob via web service (if so, suggestions?) Upload blob directly to Facebook? (Is that possible?)
I don’t see why this should not be possible doing a „normal” upload. You can create a new photo for a user by posting to PROFILE_ID/photos, with a source parameter of type multipart/form-data.
So first thing I’d try is getting the picture info from the canvas object into a „normal” form (writing it into a input element in the right format(?)), and sending that to Facebook. If this step succeeds, I’d see if jQuery or some other lib’s form.serialize method can build requests of type multipart/form-data. If that’s also possible, then there should be no further problem in taking the data in that format and posting it using FB.api (although you might want to tell your users to be patient, because that might take a while).
Can’t tell for sure if this’ll work, but I’d give it a try.
Facebook partners with Heroku for free app hosting, you can use it as the temporary server.