My hackathon team has been working the last 12 hours to use the Google Glass and Mirror APIs to play videos, in particular using the PHP library.
We tried to connect the video to the timeline element, and we tried to use the bundle option, but none of them will transmit the video.
I have no error message, and the code, as far as we can see, is correct, based on Google documentation.
Additional Information:
- We use the API to access AWS hosted videos
- We also tested videos hosted on other sites, as well as smaller videos (the one we are going to use is 20 + MB
If someone can offer some guidance, we will be very grateful! Thanks!
EDIT
This is the code structure we use directly 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โs the last iteration of the attempt to stream the video:
$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);
Easier to read in Gist: https://gist.github.com/kgardnr/1f2ce243f91cedaf9c92