2014-02-09 30 views
2

我試圖讓我的Chrome發件人應用程序將元數據發送到默認媒體接收器應用程序,但默認媒體接收器不顯示元數據。我找不到文檔或示例。有誰知道如何實現這個?下面的代碼播放音頻,但播放器不顯示任何圖像或其他元數據。Google演員:如何在默認媒體播放器中顯示元數據?

初始化:

var sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID); 
    var apiConfig = new chrome.cast.ApiConfig(sessionRequest, 
    sessionListener, 
    receiverListener); 
    chrome.cast.initialize(apiConfig, onInitSuccess, onError); 
    chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError); 

...

加載介質

url = "url-to-media" 
var mediaInfo = new chrome.cast.media.MediaInfo(url, 'audio/aac'); 
mediaInfo.metadata = new chrome.cast.media.MusicTrackMediaMetadata() 
mediaInfo.metadata.albumName = 'This is the name of the album' 
mediaInfo.metadata.artistName = 'This is the name of the artist' 
mediaInfo.metadata.songName = 'This is the name of the song' 
im = chrome.cast.Image('http://m1.behance.net/rendition/modules/575407/disp/822271229466847.png') 
mediaInfo.metadata.images = new Array(im) 
var request = new chrome.cast.media.LoadRequest(mediaInfo); 
session.loadMedia(request,onMediaDiscovered.bind(this, 'loadMedia'), onMediaError()) 

回答

4

試試這個 -

mediaInfo.metadata.title = 'This is the name of the song'; 
mediaInfo.metadata.subtitle = 'This is the name of the artist'; 
+0

謝謝!你知道這是否記錄在某個地方嗎? –

+0

有沒有辦法在默認接收器上獲取媒體圖像? –

+1

對於圖片,試試這個 - var image = new chrome.cast.Image(imageUrl); mediaInfo.metadata.images = [image];'在此處找到[https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.GenericMediaMetadata] –

1

當前默認媒體接收器應用程序接受某些元數據字段。詳細規格在這裏給出:https://developers.google.com/cast/docs/reference/messages

對於MusicTrackMediaMetaData類型,請務必將metadataType設置爲3.以下片段適用。

mediaInfo.metadata = new chrome.cast.media.MusicTrackMediaMetadata() 
mediaInfo.metadata.metadataType = 3; 
mediaInfo.metadata.title = 'This is the name of the title'; 
mediaInfo.metadata.albumArtist = 'This is the name of the album artist'; 
mediaInfo.metadata.artist = 'This is the name of the artist'; 
mediaInfo.metadata.albumName = 'This is the name of the album'; 
//mediaInfo.metadata.composer = 'composer'; 
//mediaInfo.metadata.trackNumber = 13; 
//mediaInfo.metadata.discNumber = 2; 
mediaInfo.metadata.releaseDate = '2011'; 
mediaInfo.metadata.images = [{'url': 'http://m1.behance.net/rendition/modules/575407/disp/822271229466847.png'}];    
var request = new chrome.cast.media.LoadRequest(mediaInfo); 
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError()); 

已解決一個錯誤,用於修復Chrome發件人SDK和默認接收方應用程序之間的某些不匹配。

您可以隨時製作您自己的自定義接收器應用程序,並添加您自己的自定義數據,如下所示。

var mediaInfo = new chrome.cast.media.MediaInfo(url, 'audio/mp3'); 
var request = new chrome.cast.media.LoadRequest(mediaInfo); 
var payload = { 
    "albumName": 'This is the name of the album', 
    "songName": 'This is the name of the song', 
    "thumb": 'http://m1.behance.net/rendition/modules/575407/disp/822271229466847.png', 
    "artistName": 'This is the name of the artist' 
}; 
var json = { 
    "payload": payload 
}; 
request.customData = json; 
+0

您是否有鏈接錯誤報告?無法在google-cast-sdk跟蹤器上找到它。 –

相關問題