您好我一直在使用Google Picker API(http://code.google.com/apis/picker/)。我有一个搜索YouTube电影的工作演示(下面的代码)。
此当前版本会返回所有视频。我正在尝试过滤结果,因此它只列出来自youtube.com的搜索结果。 picker API支持这一点。但我不了解API文档。
文档(http://code.google.com/apis/picker/docs/reference.html)提及“VideoSearchView.YOUTUBE”并将其描述为“适合VideoSearchView.setSite()方法的字符串常量”
我不明白如何在我的代码中实现此过滤器。任何帮助表示赞赏。
<!--
Needs work; it should only display YouTube videos.
http://code.google.com/apis/picker/docs/reference.html
Change the key parameter for a domain+path specific API key. Get one here: http://code.google.com/apis/loader/signup.html.
-->
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAANAaPTI0Sup-knGFaDbCNHBSXhCTdTCKo5q_OHnpA1qEpBIP8mRTtPnObFFbe_J21oviL78C86yxHUA"></script>
<script type="text/javascript">
google.load('picker', '1', {'language':'nl'});
function googlePicker()
{
/*
Displays the users own YouTube movies:
picker = picker.addView(google.picker.ViewId.YOUTUBE);
Displays all videos:
picker = picker.addView(google.picker.ViewId.VIDEO_SEARCH);
Displays all videos from youtube.com:
???
Example query that returns non-YouTube results: "Mobile Healing Rooms: Following Jesus on Vimeo"
*/
var picker = new google.picker.PickerBuilder();
picker = picker.addView(google.picker.ViewId.VIDEO_SEARCH);
picker = picker.enableFeature(google.picker.Feature.NAV_HIDDEN);
picker = picker.setTitle('Selecteer een YouTube video');
picker = picker.setCallback(googlePickerCallback);
picker = picker.build();
picker.setVisible(true);
}
function googlePickerCallback(data) {
var youTubeUrl = (data.action == google.picker.Action.PICKED) ? data.docs[0].url : '';
if (youTubeUrl != '')
{
$('#block_youtube_url').val(youTubeUrl);
}
}
</script>
答案 0 :(得分:1)
尝试相当于以下内容:
// Create and render a Picker object for searching YouTube videos.
function createPicker() {
var picker = new google.picker.PickerBuilder().
addView(new google.picker.VideoSearchView().
setSite(google.picker.VideoSearchView.YOUTUBE)).
setCallback(pickerCallback).
build();
picker.setVisible(true);
}
如果您通过ViewId添加视图,则无法调用特定于视图的方法。这就是暴露一些View派生类的原因。