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