6

私は自分のYouTubeプレイリストの1つからのYouTubeビデオを表示するアプリに取り組んでいます。私はこれを行うためにYouTubeAndroidAPIを使用しています。YouTubeThumbnailViewを使用して動画を表示しています。もちろん、1つのYouTubeThumbnailViewで再生リストを取得できますが、再生リストからすべての動画を取得して文字列配列に保存し、表示するListViewを作成する方法を探しています。すべてのビデオ。

したがって、必要なのはIDだけです。そうすれば、これを機能させることができます。ビデオウォールのデモを見ましたが、Nexus 7のFC以外に、必要なものが見つかりません。

4

1 に答える 1

5

おっと!それにあなたを打ち負かす:-)

ブログへのリンク

ビデオのリスト

JSON配列データを解析し、正しい文字列を取得する必要があります。

このようなもの:

 // For further information about the syntax of this request and JSON-C
 // see the documentation on YouTube http://code.google.com/apis/youtube/2.0/developers_guide_jsonc.html

  // Get are search result items
  JSONArray jsonArray = json.getJSONObject("data").getJSONArray("items");


        // Create a list to store are videos in
        List<Video> videos = new ArrayList<Video>();
        // Loop round our JSON list of videos creating Video objects to use within our app
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            // The title of the video
            String title = jsonObject.getString("title");
            // The url link back to YouTube, this checks if it has a mobile url
            // if it doesnt it gets the standard url
            String url;
            try {
                url = jsonObject.getJSONObject("player").getString("mobile");
            } catch (JSONException ignore) {
                url = jsonObject.getJSONObject("player").getString("default");
            }
            // A url to the thumbnail image of the video
            // We will use this later to get an image using a Custom ImageView
            // Found here http://blog.blundellapps.com/imageview-with-loading-spinner/
            String thumbUrl = jsonObject.getJSONObject("thumbnail").getString("sqDefault");

            // Create the video object and add it to our list
            videos.add(new Video(title, url, thumbUrl));
        }
于 2012-12-28T12:20:00.310 に答える