【问题标题】:How to get video duration and how to get only music videos via YouTube Api V3如何获取视频时长以及如何通过 YouTube Api V3 仅获取音乐视频
【发布时间】:2015-11-30 18:38:07
【问题描述】:

如何使用部分:sn-p 和 contentDetails ??我想获得持续时间,只有音乐视频,标题和观看次数.. 请帮帮我。

    function keyWordsearch() {
        gapi.client.setApiKey("MY_API_KEY");
        gapi.client.load('youtube', 'v3', function () {
            var q = $('#query').val();
            $("#result").empty();
            var request = gapi.client.youtube.search.list({
                q: q,
                part: 'snippet',

                maxResults: 5,



            });

            request.execute(function (response) {
                for (var i = 0; i < response.items.length; i++) {
                    var id = response.items[i].id.videoId;

                    var name = response.items[i].snippet.title;
                    $('#result').html($('#result').html() + "<li><a href='http://www.youtube.com/watch?v=" + id + "'>" + name + " </a></li>");
                }
                $('#result').html($('#result').html() + '</ul>');
            });
        });
    }

</script>
<script src="https://apis.google.com/js/client.js?onload=onLoadCallback"></script>

【问题讨论】:

标签: javascript api youtube


【解决方案1】:

i 写console.log(response.items[i].sn-p) 然后结果是这样的

【讨论】:

    猜你喜欢
    • 2013-01-09
    • 2018-06-28
    • 2020-11-21
    • 2017-04-13
    • 2019-09-12
    • 2014-01-26
    • 2014-06-05
    • 2015-12-07
    • 2016-01-17
    相关资源
    最近更新 更多