2014/02/12

Install YouTube plugin in PhoneGap

I develop app with PhoneGap 3.3.1, and import the YouTube plugin from YTPhoneGapPlugin.

Integrate steps:
1. Use command to install plugin
$ cordova local plugin add https://github.com/matiasmolinas/YTPhoneGapPlugin.git

2. Download YouTube api to project libs folder

3. Register the YouTube API Key from here, and fill the key in
android project/src/gdg/youtube/YouTube.java

4. Implementation
var videoId = "YSxYCMlkLsw";
var success = function() { console.log("Success"); };
var error = function(message) { console.log("Oopsie! " + message); };
window.youtube.playVideo(videoId, success, error);

If you met error message as following:
I/Web Console( 1614): Oopsie! No Activity found to handle Intent { act=com.google.android.youtube.api.StandalonePlayerActivity.START (has extras) } at file:///android_asset/www/app.js:1
Try to install YouTube app in your Android system, if you use emulator, try to download from google play and use command line to install it.
adb install com.google.android.youtube.apk
Reference


沒有留言:

張貼留言