0

可能相关:插件 videoPlayer PhoneGap 不工作

我正在尝试从适用于 Android 的 PhoneGap 3.0 应用程序播放 youtube 视频,但遇到了很多麻烦。根据有关 stackoverflow 的几个建议,我安装了 android 视频播放器插件(https://github.com/macdonst/VideoPlayer)。phonegap run android但是,当我从终端使用时,程序无法运行。这个插件在 PhoneGap 3.0 上不起作用/我应该恢复到旧版本的 phonegap 吗?

这是我在尝试运行应用程序后收到的相关输出:

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

另外,如果有人对解决此问题的另一种方法有建议,我将不胜感激:) 我尝试直接链接到 youtube 视频,但它们在浏览器中打开(而不是本机 youtube 应用程序或视频播放器)和播放音频但没有图片(当您将视频切换到全屏时,您可以看到视频)

4

3 回答 3

2

Cordova 3.0 版的新插件

https://github.com/raulduran/VideoPlayer

于 2013-10-16T16:48:54.797 回答
1

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.

于 2013-09-05T20:50:32.077 回答
0

https://github.com/macdonst/VideoPlayer/blob/master/2.2.0/src/com/phonegap/plugins/video/VideoPlayer.java

代替:

import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;

经过

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.PluginResult;
于 2013-10-16T12:08:32.047 回答