How to set/change album art?

假装没事ソ 提交于 2019-12-04 05:43:34

问题


I'm building a Cordova icecast app that has chromecast support. So far I got it working thanks to a plugin that mimmicks the official Chrome api quite closely.

The thing is: I want to set the album art of the Styled Media Receiver but I can't get it to work.. Does anybode have an example of this?

My current code (snippet)

var mediaInfo = new chrome.cast.media.MediaInfo(station.station_url);
mediaInfo.contentType = "audio/mpeg";
mediaInfo.metadata = new chrome.cast.media.MusicTrackMediaMetadata();
mediaInfo.metadata.title = station.station_name;
mediaInfo.metadata.images = [
    new chrome.cast.Image(station.station_icon), // ex: http://www.thestation.com/icon.png
    new chrome.cast.Image("img/web_hi_res_512_001.png") // fallback
];

EDIT 1: added 'new' before chrome.cast.Image(), not that it helps but this is how it's supposed to be done :)

EDIT 2: now we're on the subject of setting images using the Chrome API: how in the world can I update the image without calling loadMedia? I think that I need to use sendMessage but I don't know how to format the message. There is a page that talks about sending messages and it mentions images, but it doesn't give an example - which basically makes it useless: https://developers.google.com/cast/docs/reference/messages

PS: You can check out the project here: https://code.google.com/p/icerrr/


回答1:


Turns out that the cordova plugin I use doesn't actually do anything with the metadata I stored in the mediaInfo object. It can be a bit confusing that it mimics the Chrome API so well that you forget it's actually using the Android API to communicate with the chromecast.

So I guess I'll fork that project and try to fix it myself. Thanks for all the replies and such.



来源:https://stackoverflow.com/questions/25823031/how-to-set-change-album-art

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!