4

My hackathon team has been working the last 12+ hours to use Google Glass and the Mirror API to play a video, specifically using the PHP Library.

We have tried attaching a video to a timeline item and we have tried using the bundle option, but neither will stream the video.

I don't have an error message to show, and the code as far as we can see is correct, based on the Google Documentation.

Some more details:

  • We're using an API to access a video hosted on AWS
  • We've also tested using videos hosted on other sites as well as smaller-sized videos (the one we're aiming to use is 20+MB

If anyone can offer some guidance, we'd really appreciate it! Thank you!

EDIT

This is the code structure we're using, straight from the PHP library:

function insertAttachment($service, $itemId, $contentType, $attachment) {

  try {

    $params = array(

        'data' => $attachment,

        'mimeType' => $contentType,

        'uploadType' => 'media');

    return $service->timeline_attachments->insert($itemId, $params);

  } catch (Exception $e) {

    print 'An error ocurred: ' . $e->getMessage();

    return null;

  }

}

And here is the latest iteration of trying to get the video to stream:

       $bundle_view = $app->view();
       $bundle_view->appendData(array('total' => count($response['search']), 'video'=>$response['search'][0]));
       $bundle_html = $app->view()->fetch('bundle_home.twig');
       $new_timeline_item = new Google_TimelineItem();


       $new_timeline_item->setHtml($bundle_html);
       //$new_timeline_item->setBundleId($response['search'][0]['id']);
       $new_timeline_item->isBundleCover = 'true';
       $notification = new Google_NotificationConfig();
       $notification->setLevel("DEFAULT");
       $new_timeline_item->setNotification($notification);

       $post_result = insert_timeline_item($mirror_service, $new_timeline_item, null, null);

       error_log(print_r($post_result->getId(), true));

       $new_timeline_item->setHtmlPages("<article><section> <video src='http://www.w3schools.com/html/movie.mp4' controls> </section></article>");

       /**
       foreach ($response['search'] as $video) {
           $item = $video['videos'][0];
           $v_item = new Google_MediaFileUpload('video/vnd.google-glass.stream-url', $item, true);

           $params = array(
               'data' => $v_item,
               'mimeType' => 'video/*',
               'uploadType' => 'resumable');

           $mirror_service->timeline_attachments->insert($post_result->getId(), $params);
       }
       **/
       insert_timeline_item($mirror_service, $new_timeline_item, null, null);

Might be easier to read in a Gist: https://gist.github.com/kgardnr/1f2ce243f91cedaf9c92

kgardnr
  • 41
  • 4
  • 1
    Can you share a link to the video you're trying to stream? It's possible that it's encoded with an unsupported codec. It needs to be H.264 or H.263 in an mp4 container and it must have audio. – mimming Jul 26 '13 at 16:46
  • This is the one we're testing in the code above: http://www.w3schools.com/html/movie.mp4 Let me see if I can share the other video we tested with. – kgardnr Jul 26 '13 at 20:39
  • Got it. I'm curious about that 20MB video you mention. The one you provide in the code is about 500k. For that one you can use the same process as uploading a photo (attaching the bytes) per the quick start project. – mimming Jul 26 '13 at 21:23
  • Here is the video link: http://www.kimgardner.com/googleglass/video.mp4 – kgardnr Jul 27 '13 at 23:31

2 Answers2

1

It appears to be that in setHTMLPages where video element is used which is a blocked HTML element. Is it a root cause of the issue?

Snekithan
  • 360
  • 3
  • 11
0

Streaming video currently can't be attached through HTML, and I don't believe you can render anything on top of it. From my experience, it's also not well (or at all) included in the libraries (at least not the .NET one...I assume the PHP one is the same).

What I had to do was to build the webrequest myself, as laid out here: https://developers.google.com/glass/timeline in the streaming video section