Pregunta

I'm developing a GWT application witch reads and displays videos from youtube. With that purpose in mind I started using gwt-youtube-api.

I can display a player and play the video from youtube accordingly but I'm unable to search videos on youtube.

The following code should retrieve the most recent videos from youtube, but it doesn't do anything. After making RPC call I can't see any results for both onSucess and onFailure:

import java.util.List;

import com.google.gdata.client.youtube.YouTubeManager;
import com.google.gdata.data.youtube.VideoEntry;
import com.google.gdata.data.youtube.VideoFeed;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class Webmetalmore implements EntryPoint {

    @Override
    public void onModuleLoad() {
        YouTubeManager youTubeManager = new YouTubeManager();
        youTubeManager.retrieveMostRecent(new AsyncCallback<VideoFeed>() {

            @Override
            public void onSuccess(VideoFeed result) {
                List<VideoEntry> entries = result.getEntries();
                for (VideoEntry entry: entries){
                    System.out.println(entry.getTitle());
                }
            }

            @Override
            public void onFailure(Throwable caught) {
                GWT.log("Unable to obtain videos from youtube service", caught);
            }

        });

    }
}

Any ideas of what I'm doing wrong? Thank you

¿Fue útil?

Solución

I figured this one out. The problem is that this particular API is instantiating the YouTubeService without the required Google API key.

If I use the jars provided by the official YouTube API and instantiate the YouTubeService with the Key it works just fine.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top