如何在Vitova插件上集成Vitamio?

时间:2014-03-06 20:11:39

标签: android cordova streaming vitamio

我正在为Android上的流媒体电视创建一个应用程序,但我想整合插件Vitamio,以便它能够承受Wowza的协议。我该怎么做呢?

http://www.vitamio.org/en/

我有这段代码:

package com.tricedesigns;

import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;

import android.util.Log;

public class HelloPlugin extends Plugin {

    public static final String NATIVE_ACTION_STRING="nativeAction";
    public static final String SUCCESS_PARAMETER="success";

    @Override
    public PluginResult execute(String action, JSONArray data, String callbackId) {

         Log.d("HelloPlugin", "Hello, this is a native function called from PhoneGap/Cordova!");

         //only perform the action if it is the one that should be invoked
         if (NATIVE_ACTION_STRING.equals(action)) {

             String resultType = null;
             try {
                 resultType = data.getString(0);
             }
             catch (Exception ex) {
                 Log.d("HelloPlugin", ex.toString());
             }

             if (resultType.equals(SUCCESS_PARAMETER)) {
                 //I want to insert the Vitamio code here if possible
             }
             else {
                 return new PluginResult(PluginResult.Status.ERROR, "Oops, Error :(");
             }
         }

         return null;
    }

}

我想插入以下代码:

public class VideoViewDemo extends Activity {

    private String path = "udp://236.1.0.1:2000";
    private VideoView mVideoView;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        setContentView(R.layout.videoview);
        mVideoView = (VideoView) findViewById(R.id.surface_view);

        if (path == "") {
            // Tell the user to provide a media file URL/path.
            Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
            return;
        } else {
            mVideoView.setVideoURI(Uri.parse(path));
            mVideoView.setMediaController(new MediaController(this));
            mVideoView.requestFocus();

        }
    }
}

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

现在实际上有一个插件......我前一段时间需要它,有一天偶然发现它。

Cordova Vitamio插件| https://github.com/nchutchind/Vitamio-Cordova-Plugin

非常适合顺便说一句。

答案 2 :(得分:0)

由于违反谷歌播放政策,Cordova Vitamio插件不会在Google Play中接受..使用Cordova Exoplayer https://github.com/frontyard/cordova-exoplayer-plugin