我正在尝试让我的chrome sender应用程序将元数据发送到默认媒体接收器应用程序,但默认媒体接收器不显示元数据。我找不到文档或示例。有谁知道如何实现这个?下面的代码播放音频,但播放器不显示任何图像或其他元数据。
初始化:
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())
答案 0 :(得分:4)
试试这个 -
mediaInfo.metadata.title = 'This is the name of the song';
mediaInfo.metadata.subtitle = 'This is the name of the artist';
答案 1 :(得分:2)
我们刚刚发布了修复此问题的Cast扩展测试版。请参阅此声明:https://plus.google.com/+ShawnShen/posts/aVXSHyceNbR。
我还在github上添加了一个项目,它提供了示例代码:
答案 2 :(得分: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 Sender 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;