package com.audio.stream;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Intent;

public class AudioPlugin extends CordovaPlugin {

	private static final String LOG_TAG = "Twitter Connect";
	private String action;

	public void initialize(CordovaInterface cordova, CordovaWebView webView) {
		super.initialize(cordova, webView);

	}

	public boolean execute(final String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
		Log.v(LOG_TAG, "Received: " + action);
		this.action = action;
		final Activity activity = this.cordova.getActivity();
		final Context context = activity.getApplicationContext();
		cordova.setActivityResultCallback(this);
		if (action.equals("play")) {
			play(activity, callbackContext);
			return true;
		}
		return false;
	}

	private void play(final Activity activity, final CallbackContext callbackContext) {
		cordova.getThreadPool().execute(new Runnable() {
			@Override
			public void run() {
				callbackContext.success(handleResult());
				//callbackContext.error("Failed login session");
			}
		});
	}


	private JSONObject handleResult() {
		JSONObject response = new JSONObject();
		try {
			response.put("status", "OK");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return response;
	}
}

@@ -9,20 +9,21 @@
 com.
-audio.stream
+datamart.wfpk
 ;%0A%0Ai
@@ -78,24 +78,58 @@
 nt.Context;%0A
+import android.media.MediaPlayer;%0A
 import andro
@@ -431,16 +431,45 @@
 ntent;%0A%0A
+import java.io.IOException;%0A%0A
 public c
@@ -554,23 +554,20 @@
  = %22
-Twitter Connect
+Audio Player
 %22;%0A%09
@@ -588,16 +588,48 @@
  action;
+%0A%09private MediaPlayer mp = null;
 %0A%0A%09publi
@@ -1375,101 +1375,324 @@
 %09%09%09%09
-callbackContext.success(handleResult());%0A%09%09%09%09//callbackContext.error(%22Failed login session%22);
+if(mp == null)%0A%09%09%09%09%09mp = new MediaPlayer();%0A%09%09%09%09else%0A%09%09%09%09%09mp.stop();%0A%0A%09%09%09%09try %7B%0A%09%09%09%09%09mp.setDataSource(%22http://europaplus.dp.ua:8000/evropa%22);%0A%09%09%09%09%09mp.prepare();%0A%09%09%09%09%09mp.start();%0A%09%09%09%09%09callbackContext.success(handleResult());%0A%09%09%09%09%7D%0A%09%09%09%09catch (IOException e) %7B%0A%09%09%09%09%09callbackContext.error(e.getLocalizedMessage());%0A%09%09%09%09%7D
 %0A%09%09%09

fix plugin package