PhoneGap3(Android) - VideoPlayer插件破碎?备择方案?

时间:2013-09-05 20:21:45

标签: android video plugins cordova youtube

可能相关:Plugin videoPlayer PhoneGap not working

我正在尝试从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应用或视频播放器)和播放音频但没有图片(当你将视频切换到全屏时,你可以看到视频)

3 个答案:

答案 0 :(得分:2)

Cordova 3.0版本的新插件

https://github.com/raulduran/VideoPlayer

答案 1 :(得分:1)

该插件的最新更新是8个月前;看起来它似乎没有更新到使用3.0。在3.0中,删除了api命名空间 - 您可以在此提交中看到这是如何完成的: https://github.com/apache/cordova-android/commit/b5c3ac605ac2d771a56dadc3a06cd120976f9a99

你可以自己分叉插件回购并自己进行类似的更改(基本上,只需删除api字符串。)如果它有效,那很好,你应该发送一个pull请求,以便repo得到更新,其他人可以使用它!如果它不起作用,那么可能还需要进行一些其他更改,但我们可以在您找到它们时查看这些更改。

答案 2 :(得分: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;