2013-07-26 31 views
4

我的hackathon團隊在過去的12個多小時內一直在使用Google Glass和Mirror API播放視頻,尤其是使用PHP庫。無法在Google Glass上獲取視頻流(附件選項或套餐選項)

我們已經嘗試將視頻附加到時間軸項目,我們嘗試使用包選項,但都不會流式傳輸視頻。

我沒有要顯示的錯誤消息,並且根據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

+1

你能分享一個鏈接到你想流視頻https://developers.google.com/glass/timeline?它可能是用不支持的編解碼器編碼的。它需要在mp4容器中爲H.264或H.263,並且必須具有音頻。 – mimming

+0

這是我們在上面的代碼中測試的一個:http://www.w3schools.com/html/movie.mp4 讓我看看我能不能分享我們測試過的其他視頻。 – kgardnr

+0

明白了。我對你提到的20MB視頻感到好奇。你在代碼中提供的約爲500k。對於那個人,您可以使用與每個快速啓動項目上傳照片(附加字節)相同的過程。 – mimming

回答

1

它看起來像在使用視頻元素的setHTMLPages中,這是一個阻止的HTML元素。這是問題的根源嗎?

0

流式視頻目前無法通過HTML連接,我不相信您可以渲染任何東西。從我的經驗來看,它也不是很好(或者完全)包含在庫中(至少不是.NET的......我假設PHP是一樣的)。

我必須做的是建立自己的WebRequest,如下佈局:在視頻流部分