// Path: player-android/src/com/dxyh/fqrtmpplayer/gui/UiTools.java
// public class UiTools {
//     @SuppressWarnings("unused")
//     private static final String TAG = "UiTools";
//     
//     public interface OnInputDialogClickListener {
//         public void onClick(DialogInterface dialog, final String input);
//     }
//     public static void inputDialog(Activity activity, final String title,
//             final String hint,
//             final OnInputDialogClickListener positive_listener,
//             final OnInputDialogClickListener negative_listener) {
//         final EditText edit = new EditText(MyApplication.getAppContext());
//         edit.setFocusable(true);
//         if (!TextUtils.isEmpty(hint)) {
//             edit.setHint(hint);
//         } else {
//             edit.setHint(R.string.edit_hint);
//         }
//         edit.setSingleLine(true);
//         edit.setSelection(edit.getText().toString().length());
//         
//         AlertDialog.Builder builder =
//                 new AlertDialog.Builder(activity);
//         builder.setTitle(title)
//                .setIcon(android.R.drawable.ic_dialog_info)
//                .setView(edit)
//                .setCancelable(false)
//                .setPositiveButton(R.string.dialog_positive_btn_label,new Dialog.OnClickListener() {
//                     @Override
//                     public void onClick(DialogInterface dialog, int which) {
//                         if (positive_listener != null)
//                             positive_listener.onClick(dialog, edit.getText().toString());
//                     }})
//                .setNegativeButton(R.string.dialog_negative_btn_label, new Dialog.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        if (negative_listener != null)
//                            negative_listener.onClick(dialog, edit.getText().toString());
//                    }});
//         builder.show();
//     }
//     
//     public static final int SHORT_TOAST = Toast.LENGTH_SHORT;
//     public static final int LONG_TOAST = Toast.LENGTH_LONG;
//     
//     public static void toast(final Activity activity, final String text, final int duration) {
//         activity.runOnUiThread(new Runnable() {
//             @Override
//             public void run() {
//                 Toast.makeText(activity, text, duration).show();
//             }
//         });
//     }
//     
//     public static void adjust_brightness(final Activity activity, final float brightness) {
//         activity.runOnUiThread(new Runnable() {
//             @Override
//             public void run() {
//                 Window win = activity.getWindow();
//                 
//                 int mode = Settings.System.getInt(
//                         activity.getContentResolver(),
//                         Settings.System.SCREEN_BRIGHTNESS_MODE,
//                         Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
//                 if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
//                     WindowManager.LayoutParams winParams = win.getAttributes();
//                     winParams.screenBrightness = brightness;
//                     win.setAttributes(winParams);
//                 }
//             }
//         });
//     }
// }


import com.dxyh.fqrtmpplayer.aidl.IClientCallback;
import com.dxyh.fqrtmpplayer.aidl.IPlayer;
import com.dxyh.fqrtmpplayer.gui.UiTools;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import android.view.SurfaceView;

        public void onPrepared(IPlayer player) throws RemoteException {
            Log.i(TAG, "onPrepared");
            mHandler.sendEmptyMessage(ON_PREPARED);
        }

        @Override
        public void onCompletion(IPlayer player) throws RemoteException {
            Log.i(TAG, "onCompletion");
            mHandler.sendEmptyMessage(ON_COMPLETION);
        }

        @Override
        public void onBufferingUpdateListener(IPlayer player, int percent) throws RemoteException {
            Log.i(TAG, "onBufferingUpdateListener");
            Message msg = mHandler.obtainMessage(ON_BUFFERING, percent, 0);
            mHandler.sendMessage(msg);
        }

        @Override
        public boolean onError(IPlayer player, int what, int extra) throws RemoteException {
            Log.i(TAG, "onError");
            Message msg = mHandler.obtainMessage(ON_ERROR, what, extra);
            mHandler.sendMessage(msg);
            return true;
        }
    };
	
	@Override
	public void process(final String url) {
	    if (TextUtils.isEmpty(url)) {

// Path: player-android/src/com/dxyh/fqrtmpplayer/gui/UiTools.java
// public class UiTools {
//     @SuppressWarnings("unused")
//     private static final String TAG = "UiTools";
//     
//     public interface OnInputDialogClickListener {
//         public void onClick(DialogInterface dialog, final String input);
//     }
//     public static void inputDialog(Activity activity, final String title,
//             final String hint,
//             final OnInputDialogClickListener positive_listener,
//             final OnInputDialogClickListener negative_listener) {
//         final EditText edit = new EditText(MyApplication.getAppContext());
//         edit.setFocusable(true);
//         if (!TextUtils.isEmpty(hint)) {
//             edit.setHint(hint);
//         } else {
//             edit.setHint(R.string.edit_hint);
//         }
//         edit.setSingleLine(true);
//         edit.setSelection(edit.getText().toString().length());
//         
//         AlertDialog.Builder builder =
//                 new AlertDialog.Builder(activity);
//         builder.setTitle(title)
//                .setIcon(android.R.drawable.ic_dialog_info)
//                .setView(edit)
//                .setCancelable(false)
//                .setPositiveButton(R.string.dialog_positive_btn_label,new Dialog.OnClickListener() {
//                     @Override
//                     public void onClick(DialogInterface dialog, int which) {
//                         if (positive_listener != null)
//                             positive_listener.onClick(dialog, edit.getText().toString());
//                     }})
//                .setNegativeButton(R.string.dialog_negative_btn_label, new Dialog.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        if (negative_listener != null)
//                            negative_listener.onClick(dialog, edit.getText().toString());
//                    }});
//         builder.show();
//     }
//     
//     public static final int SHORT_TOAST = Toast.LENGTH_SHORT;
//     public static final int LONG_TOAST = Toast.LENGTH_LONG;
//     
//     public static void toast(final Activity activity, final String text, final int duration) {
//         activity.runOnUiThread(new Runnable() {
//             @Override
//             public void run() {
//                 Toast.makeText(activity, text, duration).show();
//             }
//         });
//     }
//     
//     public static void adjust_brightness(final Activity activity, final float brightness) {
//         activity.runOnUiThread(new Runnable() {
//             @Override
//             public void run() {
//                 Window win = activity.getWindow();
//                 
//                 int mode = Settings.System.getInt(
//                         activity.getContentResolver(),
//                         Settings.System.SCREEN_BRIGHTNESS_MODE,
//                         Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
//                 if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
//                     WindowManager.LayoutParams winParams = win.getAttributes();
//                     winParams.screenBrightness = brightness;
//                     win.setAttributes(winParams);
//                 }
//             }
//         });
//     }
// }


// Path: player-android/src/com/dxyh/fqrtmpplayer/FQRtmpPlayer.java
import com.dxyh.fqrtmpplayer.aidl.IClientCallback;
import com.dxyh.fqrtmpplayer.aidl.IPlayer;
import com.dxyh.fqrtmpplayer.gui.UiTools;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import android.view.SurfaceView;

        public void onPrepared(IPlayer player) throws RemoteException {
            Log.i(TAG, "onPrepared");
            mHandler.sendEmptyMessage(ON_PREPARED);
        }

        @Override
        public void onCompletion(IPlayer player) throws RemoteException {
            Log.i(TAG, "onCompletion");
            mHandler.sendEmptyMessage(ON_COMPLETION);
        }

        @Override
        public void onBufferingUpdateListener(IPlayer player, int percent) throws RemoteException {
            Log.i(TAG, "onBufferingUpdateListener");
            Message msg = mHandler.obtainMessage(ON_BUFFERING, percent, 0);
            mHandler.sendMessage(msg);
        }

        @Override
        public boolean onError(IPlayer player, int what, int extra) throws RemoteException {
            Log.i(TAG, "onError");
            Message msg = mHandler.obtainMessage(ON_ERROR, what, extra);
            mHandler.sendMessage(msg);
            return true;
        }
    };
	
	@Override
	public void process(final String url) {
	    if (TextUtils.isEmpty(url)) {

	        UiTools.toast(mActivity, "Invalid play url", UiTools.SHORT_TOAST);
