Reputation: 3799
Possibly related: Plugin videoPlayer PhoneGap not working
I'm trying to play youtube videos from my PhoneGap 3.0 application for Android but have had a lot of trouble. Following several suggestions on stackoverflow I installed the android video player plugin (https://github.com/macdonst/VideoPlayer). However the program fails to run when I use phonegap run android
from the terminal. Does this plugin not work on PhoneGap 3.0 / should I revert to an older version of phonegap?
This is pertinent output I receive after attempt to run the app:
BUILD SUCCESSFUL
Total time: 1 second
Buildfile: /home/ian/shtv/platforms/android/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.0.5
[checkenv] Installed at /home/ian/android-sdk-linux_86
-setup:
[echo] Project Name: SHTV
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 18.0.1
[echo] Resolving Build Target for SHTV...
[gettarget] Project Target: Android 4.3
[gettarget] API level: 18
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /home/ian/shtv/platforms/android/bin
[mkdir] Created dir: /home/ian/shtv/platforms/android/bin/res
[mkdir] Created dir: /home/ian/shtv/platforms/android/gen
[mkdir] Created dir: /home/ian/shtv/platforms/android/bin/classes
[mkdir] Created dir: /home/ian/shtv/platforms/android/bin/dexedLibs
[echo] ----------
[echo] Resolving Dependencies for SHTV...
[dependency] Library dependencies:
[dependency] No Libraries
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 11 source files to /home/ian/shtv/platforms/android/bin/classes
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:26: error: package org.apache.cordova.api does not exist
[javac] import org.apache.cordova.api.CallbackContext;
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:27: error: package org.apache.cordova.api does not exist
[javac] import org.apache.cordova.api.CordovaPlugin;
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:28: error: package org.apache.cordova.api does not exist
[javac] import org.apache.cordova.api.PluginResult;
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:30: error: cannot find symbol
[javac] public class VideoPlayer extends CordovaPlugin {
[javac] ^
[javac] symbol: class CordovaPlugin
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:35: error: cannot find symbol
[javac] public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
[javac] ^
[javac] symbol: class CallbackContext
[javac] location: class VideoPlayer
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:36: error: package PluginResult does not exist
[javac] PluginResult.Status status = PluginResult.Status.OK;
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:36: error: package PluginResult does not exist
[javac] PluginResult.Status status = PluginResult.Status.OK;
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:44: error: package PluginResult does not exist
[javac] status = PluginResult.Status.INVALID_ACTION;
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:46: error: cannot find symbol
[javac] callbackContext.sendPluginResult(new PluginResult(status, result));
[javac] ^
[javac] symbol: class PluginResult
[javac] location: class VideoPlayer
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:48: error: cannot find symbol
[javac] callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
[javac] ^
[javac] symbol: class PluginResult
[javac] location: class VideoPlayer
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:48: error: package PluginResult does not exist
[javac] callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:50: error: cannot find symbol
[javac] callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION));
[javac] ^
[javac] symbol: class PluginResult
[javac] location: class VideoPlayer
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:50: error: package PluginResult does not exist
[javac] callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION));
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:34: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:87: error: cannot find symbol
[javac] File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:93: error: cannot find symbol
[javac] uri = Uri.parse("file://" + this.cordova.getActivity().getFilesDir() + "/" + filename);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:104: error: cannot find symbol
[javac] this.cordova.getActivity().startActivity(intent);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:109: error: cannot find symbol
[javac] InputStream in = this.cordova.getActivity().getAssets().open(fileFrom);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:112: error: cannot find symbol
[javac] FileOutputStream out = this.cordova.getActivity().openFileOutput(fileTo, Context.MODE_WORLD_READABLE);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java:124: error: cannot find symbol
[javac] PackageManager pm = this.cordova.getActivity().getPackageManager();
[javac] ^
[javac] symbol: variable cordova
[javac] Note: /home/ian/shtv/platforms/android/src/com/phonegap/plugins/video/VideoPlayer.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 20 errors
BUILD FAILED
/home/ian/android-sdk-linux_86/tools/ant/build.xml:712: The following error occurred while executing this line:
/home/ian/android-sdk-linux_86/tools/ant/build.xml:726: Compile failed; see the compiler error output for details.
Total time: 3 seconds
Also, if anyone has suggestions on another way of approaching this problem I'd appreciate it :) I've tried to link to the youtube videos directly, but they open in the browser (instead of the native youtube app or video player) and playback audio but no pictures (when you switch the video to fullscreen you can see the video however)
Upvotes: 0
Views: 2050
Reputation: 548
New plugin for version Cordova 3.0
https://github.com/raulduran/VideoPlayer
Upvotes: 2
Reputation: 548
In
replace:
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
by
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.PluginResult;
Upvotes: 0
Reputation: 5376
The last update on that plugin was 8 months ago; it doesn't look like it has been updated to work with 3.0. In 3.0, the api
namespace was removed - you can see how this was done in this commit:
https://github.com/apache/cordova-android/commit/b5c3ac605ac2d771a56dadc3a06cd120976f9a99
You can probably just fork that plugin repo and make similar changes yourself (basically, just remove the api
string.) If it works, that's great, you should send a pull request so that the repo gets updated and other people can use it! If it doesn't work, then there might be some other changes that need to happen, but we can take a look at those when you find them.
Upvotes: 1