在过去的 12 个多小时里,我的黑客马拉松团队一直在努力使用 Google Glass 和 Mirror API 来播放视频,特别是使用 PHP 库。
我们已尝试将视频附加到时间轴项目,我们已尝试使用捆绑选项,但都不会流式传输视频。
我没有要显示的错误消息,据我们所知,代码是正确的,基于 Google 文档。
更多细节:
- 我们正在使用 API 访问托管在 AWS 上的视频
- 我们还使用其他网站上托管的视频以及 较小的视频(我们打算使用的是 20+MB
如果有人能提供一些指导,我们将不胜感激!谢谢!
编辑
这是我们使用的代码结构,直接来自 PHP 库:
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;
}
}
这是尝试让视频流式传输的最新迭代:
$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);
在 Gist 中可能更容易阅读:https://gist.github.com/kgardnr/1f2ce243f91cedaf9c92
最佳答案
似乎在 setHTMLPages 中使用了视频元素,这是一个被阻止的 HTML 元素。这是问题的根本原因吗?
关于php - 无法在 Google Glass 上播放视频(附件选项或捆绑选项),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17882492/