视频监控初始化重复打开视频页面–解决第二次打开看不到页面的情况

  • Post author:
  • Post category:其他


package com.wbkj.moretools.playvideo;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.githang.statusbar.StatusBarCompat;
import com.hikvision.netsdk.ExceptionCallBack;
import com.hikvision.netsdk.HCNetSDK;
import com.hikvision.netsdk.INT_PTR;
import com.hikvision.netsdk.NET_DVR_COMPRESSIONCFG_V30;
import com.hikvision.netsdk.NET_DVR_DEVICEINFO_V30;
import com.hikvision.netsdk.NET_DVR_PLAYBACK_INFO;
import com.hikvision.netsdk.NET_DVR_PREVIEWINFO;
import com.hikvision.netsdk.PTZCommand;
import com.hikvision.netsdk.PlaybackControlCommand;
import com.hikvision.netsdk.RealPlayCallBack;
import com.wbkj.moretools.R;
import com.wbkj.moretools.activity.BaseActivity;
import com.wbkj.moretools.util.KLog;
import com.wbkj.moretools.util.MyUtils;
import com.wbkj.moretools.view.MyListView;

import org.MediaPlayer.PlayM4.Player;

import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;


public class DemoActivity extends BaseActivity implements OnClickListener {

    private NET_DVR_DEVICEINFO_V30 m_oNetDvrDeviceInfoV30 = null;

    private int m_iLogID = -1; // return by NET_DVR_Login_v30
    private int m_iPlayID = -1; // return by NET_DVR_RealPlay_V30
    private int m_iPlaybackID = -1; // return by NET_DVR_PlayBackByTime

    private int m_iPort = -1; // play port
    private int m_iStartChan = 0; // 通道起始遍号
    private int m_iChanNum = 0; // 通道数
    private static PlaySurfaceView[] playView;

    private final String TAG = "DemoActivity";

    private boolean m_bTalkOn = false;
    private boolean m_bPTZL = false;
    private boolean m_bMultiPlay = false;
    private boolean m_bNeedDecode = true;//是否可以开启预览
    private boolean m_bSaveRealData = false;
    private boolean m_bStopPlayback = false;
    private ImageView iv_back;
    private SurfaceView Sur_Player;
    private TextView tv_num1;
    private TextView tv_num2;
    private TextView tv_num3;
    private TextView tv_num4;
    private ImageView iv_go_back;
    private ImageView iv_start_stop;
    private ImageView iv_go_forward;
    private ImageView tv_left;
    private ImageView tv_right;
    private ImageView tv_up;
    private ImageView tv_down;
    private LinearLayout ll_up_down;
    private MyListView lv_chose_video;
    private TextView tv_play_right;
    private String ip;
    private int port;
    private String username;
    private String psd;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CrashUtil crashUtil = CrashUtil.getInstance();
        crashUtil.init(this);
        StatusBarCompat.setStatusBarColor(this, getResources().getColor(R.color.xj_title), false);
        setContentView(R.layout.activity_demo);

        if (!initeSdk()) {
            this.finish();
            return;
        }

        if (!initeActivity()) {
            this.finish();
            return;
        }
    }
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putInt("m_iPort", m_iPort);
        super.onSaveInstanceState(outState);
        Log.i(TAG, "onSaveInstanceState");
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        m_iPort = savedInstanceState.getInt("m_iPort");
        super.onRestoreInstanceState(savedInstanceState);
        Log.i(TAG, "onRestoreInstanceState");
    }

    //初始化sdk
    private boolean initeSdk() {
        // init net sdk
        if (!HCNetSDK.getInstance().NET_DVR_Init()) {
            Log.e(TAG, "HCNetSDK init is failed!");
            MyUtils.showToast(DemoActivity.this, "初始化失败!");
            return false;
        }
        HCNetSDK.getInstance().NET_DVR_SetLogToFile(3, "/mnt/sdcard/sdklog/",
                true);
        MyUtils.showToast(DemoActivity.this, "初始化成功!");
        return true;
    }

    // GUI init
    private boolean initeActivity() {
        playView= new PlaySurfaceView[4];
        initView();//查找id
        return true;
    }

    private void ChangeSingleSurFace(boolean bSingle) {
        DisplayMetrics metric = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metric);

        for (int i = 0; i < 4; i++) {
            if (playView[i] == null) {
                playView[i] = new PlaySurfaceView(this);
                playView[i].setParam(metric.widthPixels);
                FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.WRAP_CONTENT,
                        FrameLayout.LayoutParams.WRAP_CONTENT);
                params.topMargin = playView[i].getM_iHeight() - (i / 2)
                        * playView[i].getM_iHeight();
                params.leftMargin = (i % 2) * playView[i].getM_iWidth();
                params.gravity = Gravity.TOP | Gravity.LEFT;
                addContentView(playView[i], params);
                playView[i].setVisibility(View.INVISIBLE);

            }
        }

        if (bSingle) {
            for (int i = 0; i < 4; ++i) {
                playView[i].setVisibility(View.INVISIBLE);
            }
            playView[0].setParam(metric.widthPixels * 2);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT,
                    FrameLayout.LayoutParams.WRAP_CONTENT);
            params.topMargin = playView[3].getM_iHeight() - (3 / 2)
                    * playView[3].getM_iHeight();
//            params.bottomMargin = 0;
            params.leftMargin = 0;
            // params.
            params.gravity = Gravity.TOP | Gravity.LEFT;
            playView[0].setLayoutParams(params);
            playView[0].setVisibility(View.VISIBLE);
            KLog.e("9999999999999999999999999");
        } else {
            for (int i = 0; i < 4; ++i) {
                playView[i].setVisibility(View.VISIBLE);
            }

            playView[0].setParam(metric.widthPixels);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT,
                    FrameLayout.LayoutParams.WRAP_CONTENT);
            params.topMargin = playView[0].getM_iHeight() - (0 / 2)
                    * playView[0].getM_iHeight();
            params.leftMargin = (0 % 2) * playView[0].getM_iWidth();
            params.gravity = Gravity.TOP | Gravity.LEFT;
            playView[0].setLayoutParams(params);
        }

    }

    // get controller instance
    private void findViews() {
    }

    // listen
    private void setListeners() {
//        m_oLoginBtn.setOnClickListener(Login_Listener);
//        m_oPreviewBtn.setOnClickListener(Preview_Listener);
//        m_oPlaybackBtn.setOnClickListener(Playback_Listener);
//        m_oParamCfgBtn.setOnClickListener(ParamCfg_Listener);
//        m_oCaptureBtn.setOnClickListener(Capture_Listener);
//        m_oRecordBtn.setOnClickListener(Record_Listener);
//        m_oTalkBtn.setOnClickListener(Talk_Listener);
//        m_oOtherBtn.setOnClickListener(OtherFunc_Listener);
//        m_oPTZBtn.setOnTouchListener(PTZ_Listener);
//        btn_up.setOnClickListener(up_Listener);
//        btn_down.setOnClickListener(down_Listener);
    }

    //摄像头登录
    public void videoLogin() {
        try {
            if (m_iLogID < 0) {
                // login on the device
                m_iLogID = loginNormalDevice();

                if (m_iLogID < 0) {
                    Log.e(TAG, "This device logins failed!");
                    MyUtils.showToast(DemoActivity.this, "摄像头链接失败!");
                    return;
                } else {
                    System.out.println("m_iLogID=" + m_iLogID);

                }
                // get instance of exception callback and set
                ExceptionCallBack oexceptionCbf = getExceptiongCbf();
                if (oexceptionCbf == null) {
                    Log.e(TAG, "ExceptionCallBack object is failed!");
                    return;
                }

                if (!HCNetSDK.getInstance().NET_DVR_SetExceptionCallBack(
                        oexceptionCbf)) {
                    Log.e(TAG, "NET_DVR_SetExceptionCallBack is failed!");
                    return;
                }

//                m_oLoginBtn.setText("Logout");
//                ConfigTest.TEST_Config(m_iPlayID, m_iLogID, m_iStartChan);
//                // HttpTest.Test_HTTP();
//                ScreenTest.TEST_Screen(m_iLogID);
                MyUtils.showToast(DemoActivity.this, "登陆成功!" + m_iLogID);
//                capture_photo();

            }
        } catch (Exception err) {
            Log.e(TAG, "error:logoin: " + err.toString());
        }
    }

    //退出摄像头
    public void videoLogoOut() {
        try {
            // whether we have logout
            if (!HCNetSDK.getInstance().NET_DVR_Logout_V30(m_iLogID)) {
                Log.e(TAG, " NET_DVR_Logout is failed!");
//                MyUtils.showToast(DemoActivity.this, "登出失败!");
                return;
            }
//            m_oLoginBtn.setText("Login");
            m_iLogID = -1;
        } catch (Exception e) {
            Log.e(TAG, "error: " + e.toString());
        }
    }

    //摄像头开启预览--是修改的这个方法
    public void startVideoPreView() {
        try {
            if (m_iLogID < 0) {
                Log.e(TAG, "please login on device first");
                MyUtils.showToast(DemoActivity.this, "请先连接摄像头!");

                return;
            }

            if (m_iPlaybackID >= 0) {
                Log.i(TAG, "Please stop palyback first");
                return;
            }

            if (m_bNeedDecode) {
                KLog.e("1111111111可以开启预览");
                if (m_iChanNum > 1)// 预览多通道
                {
                    if (!m_bMultiPlay) {
                        startMultiPreview();
                        m_bMultiPlay = true;
//                        m_oPreviewBtn.setText("Stop");
                    } else {
                        stopMultiPreview();
                        m_bMultiPlay = false;
//                        m_oPreviewBtn.setText("Preview");
                    }
                } else {// 预览单通道
                    if (m_iPlayID < 0) {
                        KLog.e("11111111111111111112");
                        startSinglePreview();
                        MyUtils.showToast(DemoActivity.this, "开启预览成功!");
                    } else {
                        stopSinglePreview();
                        MyUtils.showToast(DemoActivity.this, "关闭预览成功!");
                    }
                }
            } else {

            }
        } catch (Exception err) {
            Log.e(TAG, "error1: " + err.toString());
        }
    }
    //停止预览
    public void stopVideoPreView() {

    }


    // ptz listener
    private OnTouchListener PTZ_Listener = new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            try {
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on a device first");
                    return false;
                }
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    if (m_bPTZL == false) {
                        if (!HCNetSDK.getInstance().NET_DVR_PTZControl_Other(
                                m_iLogID, m_iStartChan, PTZCommand.PAN_LEFT, 0)) {
                            Log.e(TAG,
                                    "start PAN_LEFT failed with error code: "
                                            + HCNetSDK.getInstance()
                                            .NET_DVR_GetLastError());
                        } else {
                            Log.i(TAG, "start PAN_LEFT succ");
                        }
                    } else {
                        if (!HCNetSDK.getInstance()
                                .NET_DVR_PTZControl_Other(m_iLogID,
                                        m_iStartChan, PTZCommand.PAN_RIGHT, 0)) {
                            Log.e(TAG,
                                    "start PAN_RIGHT failed with error code: "
                                            + HCNetSDK.getInstance()
                                            .NET_DVR_GetLastError());
                        } else {
                            Log.i(TAG, "start PAN_RIGHT succ");
                        }
                    }
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    if (m_bPTZL == false) {
                        if (!HCNetSDK.getInstance().NET_DVR_PTZControl_Other(
                                m_iLogID, m_iStartChan, PTZCommand.PAN_LEFT, 1)) {
                            Log.e(TAG, "stop PAN_LEFT failed with error code: "
                                    + HCNetSDK.getInstance()
                                    .NET_DVR_GetLastError());
                        } else {
                            Log.i(TAG, "stop PAN_LEFT succ");
                        }
                        m_bPTZL = true;
//                        m_oPTZBtn.setText("PTZ(R)");
                    } else {
                        if (!HCNetSDK.getInstance()
                                .NET_DVR_PTZControl_Other(m_iLogID,
                                        m_iStartChan, PTZCommand.PAN_RIGHT, 1)) {
                            Log.e(TAG,
                                    "stop PAN_RIGHT failed with error code: "
                                            + HCNetSDK.getInstance()
                                            .NET_DVR_GetLastError());
                        } else {
                            Log.i(TAG, "stop PAN_RIGHT succ");
                        }
                        m_bPTZL = false;
//                        m_oPTZBtn.setText("PTZ(L)");
                    }
                }
                return true;
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
                return false;
            }
        }
    };
    // preset listener
    private OnClickListener OtherFunc_Listener = new OnClickListener() {
        public void onClick(View v) {
            // PTZTest.TEST_PTZ(m_iPlayID, m_iLogID, m_iStartChan);
            // ConfigTest.Test_ScreenConfig(m_iLogID, m_iStartChan);
            // PTZTest.TEST_PTZ(m_iPlayID, m_iLogID, m_iStartChan);

            /*
             * try { //PictureTest.PicUpload(m_iLogID); } catch
             * (InterruptedException e) { // TODO Auto-generated catch block
             * e.printStackTrace(); }
             */

            // PictureTest.BaseMap(m_iLogID);
            // DecodeTest.PicPreview(m_iLogID);
            // ManageTest.TEST_Manage(m_iLogID);
            // AlarmTest.Test_SetupAlarm(m_iLogID);
            // OtherFunction.TEST_OtherFunc(m_iPlayID, m_iLogID, m_iStartChan);
            // JNATest.TEST_Config(m_iPlayID, m_iLogID, m_iStartChan);
            ConfigTest.TEST_Config(m_iPlayID, m_iLogID, m_iStartChan);
            // HttpTest.Test_HTTP();
            ScreenTest.TEST_Screen(m_iLogID);
        }
    };
    // Talk listener
    private OnClickListener Talk_Listener = new OnClickListener() {
        public void onClick(View v) {
            try {
                if (m_bTalkOn == false) {
                    if (VoiceTalk.startVoiceTalk(m_iLogID) >= 0) {
                        m_bTalkOn = true;
//                        m_oTalkBtn.setText("Stop");
                    }
                } else {
                    if (VoiceTalk.stopVoiceTalk()) {
                        m_bTalkOn = false;
//                        m_oTalkBtn.setText("Talk");
                    }
                }
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
            }
        }
    };
    // record listener
    private OnClickListener Record_Listener = new OnClickListener() {
        public void onClick(View v) {
            if (!m_bSaveRealData) {
                if (!HCNetSDK.getInstance().NET_DVR_SaveRealData(m_iPlayID,
                        "/sdcard/test.mp4")) {
                    System.out.println("NET_DVR_SaveRealData failed! error: "
                            + HCNetSDK.getInstance().NET_DVR_GetLastError());
                    return;
                } else {
                    System.out.println("NET_DVR_SaveRealData succ!");
                }
                m_bSaveRealData = true;
            } else {
                if (!HCNetSDK.getInstance().NET_DVR_StopSaveRealData(m_iPlayID)) {
                    System.out
                            .println("NET_DVR_StopSaveRealData failed! error: "
                                    + HCNetSDK.getInstance()
                                    .NET_DVR_GetLastError());
                } else {
                    System.out.println("NET_DVR_StopSaveRealData succ!");
                }
                m_bSaveRealData = false;
            }
        }
    };
    // capture listener
    private OnClickListener Capture_Listener = new OnClickListener() {
        public void onClick(View v) {
            try {
                if (m_iPort < 0) {
                    Log.e(TAG, "please start preview first");
                    return;
                }
                Player.MPInteger stWidth = new Player.MPInteger();
                Player.MPInteger stHeight = new Player.MPInteger();
                if (!Player.getInstance().getPictureSize(m_iPort, stWidth,
                        stHeight)) {
                    Log.e(TAG, "getPictureSize failed with error code:"
                            + Player.getInstance().getLastError(m_iPort));
                    return;
                }
                int nSize = 5 * stWidth.value * stHeight.value;
                byte[] picBuf = new byte[nSize];
                Player.MPInteger stSize = new Player.MPInteger();
                if (!Player.getInstance().getBMP(m_iPort, picBuf, nSize, stSize)) {
                    Log.e(TAG, "getBMP failed with error code:"
                            + Player.getInstance().getLastError(m_iPort));
                    return;
                }

                SimpleDateFormat sDateFormat = new SimpleDateFormat(
                        "yyyy-MM-dd-hh:mm:ss");
                String date = sDateFormat.format(new Date());
                FileOutputStream file = new FileOutputStream("/mnt/sdcard/"
                        + date + ".bmp");
                file.write(picBuf, 0, stSize.value);
                file.close();
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
            }
        }
    };
   
    private OnClickListener Playback_Listener = new OnClickListener() {

        public void onClick(View v) {
            try {
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on a device first");
                    return;
                }
                if (m_iPlaybackID < 0) {
                    if (m_iPlayID >= 0) {
                        Log.i(TAG, "Please stop preview first");
                        return;
                    }

                    ChangeSingleSurFace(true);
                    m_iPlaybackID = HCNetSDK.getInstance()
                            .NET_DVR_PlayBackByName(m_iLogID,
                                    new String("ch0002_00010000459000200"), playView[0].getHolder().getSurface());
                    if (m_iPlaybackID >= 0) {
                        NET_DVR_PLAYBACK_INFO struPlaybackInfo = null;
                        if (!HCNetSDK
                                .getInstance()
                                .NET_DVR_PlayBackControl_V40(
                                        m_iPlaybackID,
                                        PlaybackControlCommand.NET_DVR_PLAYSTART,
                                        null, 0, struPlaybackInfo)) {
                            Log.e(TAG, "net sdk playback start failed!");
                            return;
                        }
                        m_bStopPlayback = false;
//                        m_oPlaybackBtn.setText("Stop");

                        Thread thread = new Thread() {
                            public void run() {
                                int nProgress = -1;
                                while (true) {
                                    nProgress = HCNetSDK.getInstance()
                                            .NET_DVR_GetPlayBackPos(
                                                    m_iPlaybackID);
                                    System.out
                                            .println("NET_DVR_GetPlayBackPos:"
                                                    + nProgress);
                                    if (nProgress < 0 || nProgress >= 100) {
                                        break;
                                    }
                                    try {
                                        Thread.sleep(1000);
                                    } catch (InterruptedException e) { // TODO
                                        // Auto-generated
                                        // catch
                                        // block
                                        e.printStackTrace();
                                    }

                                }
                            }
                        };
                        thread.start();
                    } else {
                        Log.i(TAG,
                                "NET_DVR_PlayBackByName failed, error code: "
                                        + HCNetSDK.getInstance()
                                        .NET_DVR_GetLastError());
                    }
                } else {
                    m_bStopPlayback = true;
                    if (!HCNetSDK.getInstance().NET_DVR_StopPlayBack(
                            m_iPlaybackID)) {
                        Log.e(TAG, "net sdk stop playback failed");
                    } // player stop play
//                    m_oPlaybackBtn.setText("Playback");
                    m_iPlaybackID = -1;

                    ChangeSingleSurFace(false);
                }
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
            }
        }
    };

    // login listener
    private OnClickListener Login_Listener = new OnClickListener() {
        public void onClick(View v) {
            try {
                if (m_iLogID < 0) {
                    // login on the device
                    m_iLogID = loginNormalDevice();
                    if (m_iLogID < 0) {
                        Log.e(TAG, "This device logins failed!");
                        return;
                    } else {
                        System.out.println("m_iLogID=" + m_iLogID);
                    }
                    // get instance of exception callback and set
                    ExceptionCallBack oexceptionCbf = getExceptiongCbf();
                    if (oexceptionCbf == null) {
                        Log.e(TAG, "ExceptionCallBack object is failed!");
                        return;
                    }

                    if (!HCNetSDK.getInstance().NET_DVR_SetExceptionCallBack(
                            oexceptionCbf)) {
                        Log.e(TAG, "NET_DVR_SetExceptionCallBack is failed!");
                        return;
                    }

                    Log.i(TAG,
                            "Login sucess ****************************1***************************");
                } else {
                    // whether we have logout
                    if (!HCNetSDK.getInstance().NET_DVR_Logout_V30(m_iLogID)) {
                        Log.e(TAG, " NET_DVR_Logout is failed!");
                        return;
                    }
                    m_iLogID = -1;
                }
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
            }
        }
    };
    // Preview listener
    private OnClickListener Preview_Listener = new OnClickListener() {
        public void onClick(View v) {
            try {
                ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(DemoActivity.this
                                        .getCurrentFocus().getWindowToken(),
                                InputMethodManager.HIDE_NOT_ALWAYS);
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on device first");
                    return;
                }

                if (m_iPlaybackID >= 0) {
                    Log.i(TAG, "Please stop palyback first");
                    return;
                }

                if (m_bNeedDecode) {

                    if (m_iChanNum > 1)// preview more than a channel
                    {
                        if (!m_bMultiPlay) {
                            startMultiPreview();
                            // startMultiPreview();
                            m_bMultiPlay = true;
//                            m_oPreviewBtn.setText("Stop");
                        } else {
                            stopMultiPreview();
                            m_bMultiPlay = false;
//                            m_oPreviewBtn.setText("Preview");
                        }
                    } else // preivew a channel
                    {
                        if (m_iPlayID < 0) {
                            startSinglePreview();
                        } else {
                            stopSinglePreview();
//                            m_oPreviewBtn.setText("Preview");
                        }
                    }
                } else {

                }
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
            }
        }
    };
    // configuration listener
    private OnClickListener ParamCfg_Listener = new OnClickListener() {
        public void onClick(View v) {
            try {
                paramCfg(m_iLogID);
            } catch (Exception err) {
                Log.e(TAG, "error: " + err.toString());
            }
        }
    };

    private void startSinglePreview() {
        if (m_iPlaybackID >= 0) {
            Log.i(TAG, "Please stop palyback first");
            return;
        }

        Log.e(TAG, "m_iStartChan:" + m_iStartChan);

        NET_DVR_PREVIEWINFO previewInfo = new NET_DVR_PREVIEWINFO();
        previewInfo.lChannel = m_iStartChan;
        previewInfo.dwStreamType = 0; // substream
        previewInfo.bBlocked = 1;

        RealPlayCallBack fRealDataCallBack = getRealPlayerCbf();
//        previewInfo.hHwnd = playView[0].getHolder();
//        KLog.e("ceshishuju" + previewInfo.hHwnd.toString());
        // HCNetSDK start preview
        KLog.e("这个时候的登陆id"+m_iLogID);
 
	//这个地方做的处理  解决id获取不到的问题
        m_iPlayID = HCNetSDK.getInstance().NET_DVR_RealPlay_V40(m_iLogID,
                previewInfo, fRealDataCallBack);
        KLog.e("ceshi:" + m_iPlayID);
        if (m_iPlayID < 0) {
            Log.e(TAG, "NET_DVR_RealPlay is failed!Err:"
                    + HCNetSDK.getInstance().NET_DVR_GetLastError());
            Log.e(TAG, "我看看是不是这里除了问题");

            return;
        }

        Log.e(TAG, "NetSdk Play sucess ***********************3***************************");
//        m_oPreviewBtn.setText("Stop");
    }

    private RealPlayCallBack getRealPlayerCbf() {
        RealPlayCallBack cbf = new RealPlayCallBack() {
            public void fRealDataCallBack(int iRealHandle, int iDataType, byte[] pDataBuffer, int iDataSize) {
                processRealData(1, iDataType, pDataBuffer, iDataSize, Player.STREAM_REALTIME);
            }
        };
        return cbf;
    }

    private void processRealData(int iPlayViewNo, int iDataType, byte[] pDataBuffer, int iDataSize, int iStreamMode) {
        String TAG_ERROR = "play";
        if (m_bNeedDecode) {
            if (HCNetSDK.NET_DVR_SYSHEAD == iDataType) {
                m_iPort = Player.getInstance().getPort();
                if (m_iPort == -1) {
                    Log.e(TAG_ERROR, "getPort is failed with: " + Player.getInstance().getLastError(m_iPort));
                    return;
                }
                Log.i(TAG, "getPort success with: " + m_iPort);
                if (iDataSize > 0) {
                    if (!Player.getInstance().setStreamOpenMode(m_iPort, iStreamMode))  //set stream mode
                    {
                        Log.e(TAG_ERROR, "setStreamOpenMode failed");
                        return;
                    }
                    if (!Player.getInstance().openStream(m_iPort, pDataBuffer, iDataSize, 2 * 1024 * 1024)) //open stream
                    {
                        Log.e(TAG_ERROR, "openStream failed");
                        return;
                    }
                    if (!Player.getInstance().play(m_iPort,playView[0].getHolder())) {
                        Log.e(TAG_ERROR, "play failed");
                        return;
                    }
                    if (!Player.getInstance().playSound(m_iPort)) {
                        Log.e(TAG_ERROR, "playSound failed with error code:" + Player.getInstance().getLastError(m_iPort));
                        return;
                    }
                }
            } else {
                if (!Player.getInstance().inputData(m_iPort, pDataBuffer, iDataSize)) {
                    for (int i = 0; i < 4000 && m_iPlaybackID >= 0 && !m_bStopPlayback; i++) {
                        if (Player.getInstance().inputData(m_iPort, pDataBuffer, iDataSize)) {
                            break;
                        }
                        if (i % 100 == 0) {
                            Log.e(TAG_ERROR, "inputData failed with: " + Player.getInstance().getLastError(m_iPort) + ", i:" + i);
                        }
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }


    private void startMultiPreview() {

        for (int i = 0; i < 4; i++) {
            KLog.e("仅仅测试是否开启多通道预览及数量"+i);
            playView[i].startPreview(m_iLogID, m_iStartChan + i);
        }

        m_iPlayID = playView[0].m_iPreviewHandle;
    }

    private void stopMultiPreview() {
        int i = 0;
        for (i = 0; i < 4; i++) {
            playView[i].stopPreview();
        }
        m_iPlayID = -1;
    }

    //stopSinglePreview   stop preview  停止预览
    private void stopSinglePreview() {
        if (m_iPlayID < 0) {
            Log.e(TAG, "m_iPlayID < 0");
            return;
        }

        // net sdk stop preview
        if (!HCNetSDK.getInstance().NET_DVR_StopRealPlay(m_iPlayID)) {
            Log.e(TAG, "StopRealPlay is failed!Err:"
                    + HCNetSDK.getInstance().NET_DVR_GetLastError());
            return;
        }

        m_iPlayID = -1;
    }

    //抓图
    public void capture_photo(){
        OtherFunction.Test_CaptureJpegPicture(m_iLogID,m_iStartChan);

    }




    //login on device  登陆设备  设置ip等相关信息
    private int loginNormalDevice() {
        int iLogID = -1;
        // get instance
        m_oNetDvrDeviceInfoV30 = new NET_DVR_DEVICEINFO_V30();
        if (null == m_oNetDvrDeviceInfoV30) {
            Log.e(TAG, "HKNetDvrDeviceInfoV30 new is failed!");
            return -1;
        }
        String strIP = ip;
        int nPort = port;
        String strUser =username;
        String strPsd = psd;


        // call NET_DVR_Login_v30 to login on, port 8000 as default
        iLogID = HCNetSDK.getInstance().NET_DVR_Login_V30(strIP, nPort,
                strUser, strPsd, m_oNetDvrDeviceInfoV30);
        if (iLogID < 0) {
            MyUtils.showToast(DemoActivity.this, "摄像头登录时链接失败!");
            Log.e(TAG, "NET_DVR_Login is failed!Err:"
                    + HCNetSDK.getInstance().NET_DVR_GetLastError());
            return -1;
        }
        if (m_oNetDvrDeviceInfoV30.byChanNum > 0) {
            

            m_iChanNum = m_oNetDvrDeviceInfoV30.byChanNum;

        } else if (m_oNetDvrDeviceInfoV30.byIPChanNum > 0) {
//            先注释掉
//            m_iStartChan = m_oNetDvrDeviceInfoV30.byStartDChan;
            m_iChanNum = 1/*m_oNetDvrDeviceInfoV30.byIPChanNum
                    + m_oNetDvrDeviceInfoV30.byHighDChanNum * 256*/;

//            m_iChanNum = m_oNetDvrDeviceInfoV30.byIPChanNum
//                    + m_oNetDvrDeviceInfoV30.byHighDChanNum * 256;


        }
        KLog.e("登陆后数据"+"m_iStartChan:"+m_iStartChan+"m_iChanNum:"+m_iChanNum);

        if (m_iChanNum > 1) {
            KLog.e("88888888开启多通道");
            ChangeSingleSurFace(false);
        } else {
            ChangeSingleSurFace(true);
        }
        Log.i(TAG, "NET_DVR_Login is Successful!");

        return iLogID;
    }

    public static void Test_XMLAbility(int iUserID) {
        byte[] arrayOutBuf = new byte[64 * 1024];
        INT_PTR intPtr = new INT_PTR();
        String strInput = new String(
                "<AlarmHostAbility version=\"2.0\"></AlarmHostAbility>");
        byte[] arrayInBuf = new byte[8 * 1024];
        arrayInBuf = strInput.getBytes();
        if (!HCNetSDK.getInstance().NET_DVR_GetXMLAbility(iUserID,
                HCNetSDK.DEVICE_ABILITY_INFO, arrayInBuf, strInput.length(),
                arrayOutBuf, 64 * 1024, intPtr)) {
            System.out.println("get DEVICE_ABILITY_INFO faild!" + " err: "
                    + HCNetSDK.getInstance().NET_DVR_GetLastError());
        } else {
            System.out.println("get DEVICE_ABILITY_INFO succ!");
        }
    }

    //登陆ezviz 设配
    private int loginEzvizDevice() {
        return -1;
      
    }



    //配置 configuration
    private void paramCfg(final int iUserID) {
        // whether have logined on
        if (iUserID < 0) {
            Log.e(TAG, "iUserID < 0");
            return;
        }

        NET_DVR_COMPRESSIONCFG_V30 struCompress = new NET_DVR_COMPRESSIONCFG_V30();
        if (!HCNetSDK.getInstance().NET_DVR_GetDVRConfig(iUserID,
                HCNetSDK.NET_DVR_GET_COMPRESSCFG_V30, m_iStartChan,
                struCompress)) {
            Log.e(TAG, "NET_DVR_GET_COMPRESSCFG_V30 failed with error code:"
                    + HCNetSDK.getInstance().NET_DVR_GetLastError());
        } else {
            Log.i(TAG, "NET_DVR_GET_COMPRESSCFG_V30 succ");
        }
        // set substream resolution to cif
        struCompress.struNetPara.byResolution = 1;
        if (!HCNetSDK.getInstance().NET_DVR_SetDVRConfig(iUserID,
                HCNetSDK.NET_DVR_SET_COMPRESSCFG_V30, m_iStartChan,
                struCompress)) {
            Log.e(TAG, "NET_DVR_SET_COMPRESSCFG_V30 failed with error code:"
                    + HCNetSDK.getInstance().NET_DVR_GetLastError());
        } else {
            Log.i(TAG, "NET_DVR_SET_COMPRESSCFG_V30 succ");
        }
    }

    //process exception  异常输出
    private ExceptionCallBack getExceptiongCbf() {
        ExceptionCallBack oExceptionCbf = new ExceptionCallBack() {
            public void fExceptionCallBack(int iType, int iUserID, int iHandle) {
                System.out.println("recv exception, type:" + iType);
            }
        };
        return oExceptionCbf;
    }

    //清除 cleanup
    public void Cleanup() {
        // release net SDK resource
        HCNetSDK.getInstance().NET_DVR_Cleanup();
    }



    @Override
    protected void onStop() {
//       
        super.onStop();
        isPlaying=false;
//        new Thread() {
//            @Override
//            public void run() {
                if (HCNetSDK.getInstance().NET_DVR_Logout_V30(m_iLogID)) {
                    m_iLogID = -1;
                    Log.e(TAG, "登出设备成功!");
                } else {
                    m_iLogID = 0;
                    Log.e(TAG, "登出设备失败!"+getErrorMsg(HCNetSDK.getInstance().NET_DVR_GetLastError()));
                }
                if (HCNetSDK.getInstance().NET_DVR_Cleanup()) {
                    Log.e(TAG, "释放SDK资源成功!");
                } else {
                    Log.e(TAG, "释放SDK资源失败!");
                }
//            }
//        }.start();
    }


    /**
     * 获取错误信息
     * @param errorCode
     * @return
     */
    private String getErrorMsg(int errorCode) {
        switch (errorCode) {
            case 0:
                return "[" + errorCode + " NET_DVR_NOERROR] 没有错误。";
            case 1:
                return "[" + errorCode + " NET_DVR_PASSWORD_ERROR] 用户名密码错误。注册时输入的用户名或者密码错误。";
            case 2:
                return "[" + errorCode + " NET_DVR_NOENOUGHPRI] 权限不足。该注册用户没有权限执行当前对设备的操作,可以与远程用户参数配置做对比。";
            case 3:
                return "[" + errorCode + " NET_DVR_NOINIT] SDK未初始化。";
            case 4:
                return "[" + errorCode + " NET_DVR_CHANNEL_ERROR] 通道号错误。设备没有对应的通道号。";
            case 5:
                return "[" + errorCode + " NET_DVR_OVER_MAXLINK] 设备总的连接数超过最大。";
            case 6:
                return "[" + errorCode + " NET_DVR_VERSIONNOMATCH] 版本不匹配。SDK和设备的版本不匹配。";
            case 7:
                return "[" + errorCode + " NET_DVR_NETWORK_FAIL_CONNECT] 连接设备失败。设备不在线或网络原因引起的连接超时等。";
            case 8:
                return "[" + errorCode + " NET_DVR_NETWORK_SEND_ERROR] 向设备发送失败。";
            case 9:
                return "[" + errorCode + " NET_DVR_NETWORK_RECV_ERROR] 从设备接收数据失败。";
            case 10:
                return "[" + errorCode + " NET_DVR_NETWORK_RECV_TIMEOUT] 从设备接收数据超时。";
            case 11:
                return "[" + errorCode + " NET_DVR_NETWORK_ERRORDATA] 传送的数据有误。发送给设备或者从设备接收到的数据错误,如远程参数配置时输入设备不支持的值。";
            case 12:
                return "[" + errorCode + " NET_DVR_ORDER_ERROR] 调用次序错误。";
            case 13:
                return "[" + errorCode + " NET_DVR_OPERNOPERMIT] 无此权限。";
            case 14:
                return "[" + errorCode + " NET_DVR_COMMANDTIMEOUT] 设备命令执行超时。";
            case 15:
                return "[" + errorCode + " NET_DVR_ERRORSERIALPORT] 串口号错误。指定的设备串口号不存在。";
            case 16:
                return "[" + errorCode + " NET_DVR_ERRORALARMPORT] 报警端口错误。指定的设备报警输出端口不存在。";
            case 17:
                return "[" + errorCode + " NET_DVR_PARAMETER_ERROR] 参数错误。SDK接口中给入的输入或输出参数为空,或者参数格式或值不符合要求。";
            case 18:
                return "[" + errorCode + " NET_DVR_CHAN_EXCEPTION] 设备通道处于错误状态。";
            case 19:
                return "[" + errorCode + " NET_DVR_NODISK] 设备无硬盘。当设备无硬盘时,对设备的录像文件、硬盘配置等操作失败。";
            case 20:
                return "[" + errorCode + " NET_DVR_ERRORDISKNUM] 硬盘号错误。当对设备进行硬盘管理操作时,指定的硬盘号不存在时返回该错误。";
            case 21:
                return "[" + errorCode + " NET_DVR_DISK_FULL] 设备硬盘满。";
            case 22:
                return "[" + errorCode + " NET_DVR_DISK_ERROR] 设备硬盘出错。";
            case 23:
                return "[" + errorCode + " NET_DVR_NOSUPPORT] 设备不支持。";
            case 24:
                return "[" + errorCode + " NET_DVR_BUSY] 设备忙。";
            case 25:
                return "[" + errorCode + " NET_DVR_MODIFY_FAIL] 设备修改不成功。";
            case 26:
                return "[" + errorCode + " NET_DVR_PASSWORD_FORMAT_ERROR] 密码输入格式不正确。";
            case 27:
                return "[" + errorCode + " NET_DVR_DISK_FORMATING] 硬盘正在格式化,不能启动操作。";
            case 28:
                return "[" + errorCode + " NET_DVR_DVRNORESOURCE] 设备资源不足。";
            case 29:
                return "[" + errorCode + " NET_DVR_DVROPRATEFAILED] 设备操作失败。";
            case 30:
                return "[" + errorCode + " NET_DVR_OPENHOSTSOUND_FAIL] 语音对讲、语音广播操作中采集本地音频或打开音频输出失败。";
            case 31:
                return "[" + errorCode + " NET_DVR_DVRVOICEOPENED] 设备语音对讲被占用。";
            case 32:
                return "[" + errorCode + " NET_DVR_TIMEINPUTERROR] 时间输入不正确。";
            case 33:
                return "[" + errorCode + " NET_DVR_NOSPECFILE] 回放时设备没有指定的文件。";
            case 34:
                return "[" + errorCode + " NET_DVR_CREATEFILE_ERROR] 创建文件出错。本地录像、保存图片、获取配置文件和远程下载录像时创建文件失败。";
            case 35:
                return "[" + errorCode + " NET_DVR_FILEOPENFAIL] 打开文件出错。设置配置文件、设备升级、上传审讯文件时打开文件失败。";
            case 36:
                return "[" + errorCode + " NET_DVR_OPERNOTFINISH] 上次的操作还没有完成。";
            case 37:
                return "[" + errorCode + " NET_DVR_GETPLAYTIMEFAIL] 获取当前播放的时间出错。";
            case 38:
                return "[" + errorCode + " NET_DVR_PLAYFAIL] 播放出错。";
            case 39:
                return "[" + errorCode + " NET_DVR_FILEFORMAT_ERROR] 文件格式不正确。";
            case 40:
                return "[" + errorCode + " NET_DVR_DIR_ERROR] 路径错误。";
            case 41:
                return "[" + errorCode + " NET_DVR_ALLOC_RESOURCE_ERROR] SDK资源分配错误。";
            case 42:
                return "[" + errorCode + " NET_DVR_AUDIO_MODE_ERROR] 声卡模式错误。当前打开声音播放模式与实际设置的模式不符出错。";
            case 43:
                return "[" + errorCode + " NET_DVR_NOENOUGH_BUF] 缓冲区太小。接收设备数据的缓冲区或存放图片缓冲区不足。";
            case 44:
                return "[" + errorCode + " NET_DVR_CREATESOCKET_ERROR] 创建SOCKET出错。";
            case 45:
                return "[" + errorCode + " NET_DVR_SETSOCKET_ERROR] 设置SOCKET出错。";
            case 46:
                return "[" + errorCode + " NET_DVR_MAX_NUM] 个数达到最大。分配的注册连接数、预览连接数超过SDK支持的最大数。";
            case 47:
                return "[" + errorCode + " NET_DVR_USERNOTEXIST] 用户不存在。注册的用户ID已注销或不可用。";
            case 48:
                return "[" + errorCode + " NET_DVR_WRITEFLASHERROR] 写FLASH出错。设备升级时写FLASH失败。";
            case 49:
                return "[" + errorCode + " NET_DVR_UPGRADEFAIL] 设备升级失败。网络或升级文件语言不匹配等原因升级失败。";
            case 50:
                return "[" + errorCode + " NET_DVR_CARDHAVEINIT] 解码卡已经初始化过。";
            case 51:
                return "[" + errorCode + " NET_DVR_PLAYERFAILED] 调用播放库中某个函数失败。";
            case 52:
                return "[" + errorCode + " NET_DVR_MAX_USERNUM] 登录设备的用户数达到最大。";
            case 53:
                return "[" + errorCode + " NET_DVR_GETLOCALIPANDMACFAIL] 获得本地PC的IP地址或物理地址失败。";
            case 54:
                return "[" + errorCode + " NET_DVR_NOENCODEING] 设备该通道没有启动编码。";
            case 55:
                return "[" + errorCode + " NET_DVR_IPMISMATCH] IP地址不匹配。";
            case 56:
                return "[" + errorCode + " NET_DVR_MACMISMATCH] MAC地址不匹配。";
            case 57:
                return "[" + errorCode + " NET_DVR_UPGRADELANGMISMATCH] 升级文件语言不匹配。";
            case 58:
                return "[" + errorCode + " NET_DVR_MAX_PLAYERPORT] 播放器路数达到最大。";
            case 59:
                return "[" + errorCode + " NET_DVR_NOSPACEBACKUP] 备份设备中没有足够空间进行备份。";
            case 60:
                return "[" + errorCode + " NET_DVR_NODEVICEBACKUP] 没有找到指定的备份设备。";
            case 61:
                return "[" + errorCode + " NET_DVR_PICTURE_BITS_ERROR] 图像素位数不符,限24色。";
            case 62:
                return "[" + errorCode + " NET_DVR_PICTURE_DIMENSION_ERROR] 图片高*宽超限,限128*256。";
            case 63:
                return "[" + errorCode + " NET_DVR_PICTURE_SIZ_ERROR] 图片大小超限,限100K。";
            case 64:
                return "[" + errorCode + " NET_DVR_LOADPLAYERSDKFAILED] 载入当前目录下Player Sdk出错。";
            case 65:
                return "[" + errorCode + " NET_DVR_LOADPLAYERSDKPROC_ERROR] 找不到Player Sdk中某个函数入口。";
            case 66:
                return "[" + errorCode + " NET_DVR_LOADDSSDKFAILED] 载入当前目录下DSsdk出错。";
            case 67:
                return "[" + errorCode + " NET_DVR_LOADDSSDKPROC_ERROR] 找不到DsSdk中某个函数入口。";
            case 68:
                return "[" + errorCode + " NET_DVR_DSSDK_ERROR] 调用硬解码库DsSdk中某个函数失败。";
            case 69:
                return "[" + errorCode + " NET_DVR_VOICEMONOPOLIZE] 声卡被独占。";
            case 70:
                return "[" + errorCode + " NET_DVR_JOINMULTICASTFAILED] 加入多播组失败。";
            case 71:
                return "[" + errorCode + " NET_DVR_CREATEDIR_ERROR] 建立日志文件目录失败。";
            case 72:
                return "[" + errorCode + " NET_DVR_BINDSOCKET_ERROR] 绑定套接字失败。";
            case 73:
                return "[" + errorCode + " NET_DVR_SOCKETCLOSE_ERROR] socket连接中断,此错误通常是由于连接中断或目的地不可达。";
            case 74:
                return "[" + errorCode + " NET_DVR_USERID_ISUSING] 注销时用户ID正在进行某操作。";
            case 75:
                return "[" + errorCode + " NET_DVR_SOCKETLISTEN_ERROR] 监听失败。";
            case 76:
                return "[" + errorCode + " NET_DVR_PROGRAM_EXCEPTION] 程序异常。";
            case 77:
                return "[" + errorCode + " NET_DVR_WRITEFILE_FAILED] 写文件失败。本地录像、远程下载录像、下载图片等操作时写文件失败。";
            case 78:
                return "[" + errorCode + " NET_DVR_FORMAT_READONLY] 禁止格式化只读硬盘。";
            case 79:
                return "[" + errorCode + " NET_DVR_WITHSAMEUSERNAME] 远程用户配置结构中存在相同的用户名。";
            case 80:
                return "[" + errorCode + " NET_DVR_DEVICETYPE_ERROR] 导入参数时设备型号不匹配。";
            case 81:
                return "[" + errorCode + " NET_DVR_LANGUAGE_ERROR] 导入参数时语言不匹配。";
            case 82:
                return "[" + errorCode + " NET_DVR_PARAVERSION_ERROR] 导入参数时软件版本不匹配。";
            case 83:
                return "[" + errorCode + " NET_DVR_IPCHAN_NOTALIVE] 预览时外接IP通道不在线。";
            case 84:
                return "[" + errorCode + " NET_DVR_RTSP_SDK_ERROR] 加载标准协议通讯库StreamTransClient失败。";
            case 85:
                return "[" + errorCode + " NET_DVR_CONVERT_SDK_ERROR] 加载转封装库失败。";
            case 86:
                return "[" + errorCode + " NET_DVR_IPC_COUNT_OVERFLOW] 超出最大的IP接入通道数。";
            case 87:
                return "[" + errorCode + " NET_DVR_MAX_ADD_NUM] 添加录像标签或者其他操作超出最多支持的个数。";
            case 88:
                return "[" + errorCode + " NET_DVR_PARAMMODE_ERROR] 图像增强仪,参数模式错误(用于硬件设置时,客户端进行软件设置时错误值)。";
            case 89:
                return "[" + errorCode + " NET_DVR_CODESPITTER_OFFLINE] 码分器不在线。";
            case 90:
                return "[" + errorCode + " NET_DVR_BACKUP_COPYING] 设备正在备份。";
            case 91:
                return "[" + errorCode + " NET_DVR_CHAN_NOTSUPPORT] 通道不支持该操作。";
            case 92:
                return "[" + errorCode + " NET_DVR_CALLINEINVALID] 高度线位置太集中或长度线不够倾斜。";
            case 93:
                return "[" + errorCode + " NET_DVR_CALCANCELCONFLICT] 取消标定冲突,如果设置了规则及全局的实际大小尺寸过滤。";
            case 94:
                return "[" + errorCode + " NET_DVR_CALPOINTOUTRANGE] 标定点超出范围。";
            case 95:
                return "[" + errorCode + " NET_DVR_FILTERRECTINVALID] 尺寸过滤器不符合要求。";
            case 96:
                return "[" + errorCode + " NET_DVR_DDNS_DEVOFFLINE] 设备没有注册到ddns上。";
            case 97:
                return "[" + errorCode + " NET_DVR_DDNS_INTER_ERROR] DDNS 服务器内部错误。";
            case 99:
                return "[" + errorCode + " NET_DVR_DEC_CHAN_REBIND] 解码通道绑定显示输出次数受限。";
            case 150:
                return "[" + errorCode + " NET_DVR_ALIAS_DUPLICATE] 别名重复(HiDDNS的配置)。";
            case 200:
                return "[" + errorCode + " NET_DVR_NAME_NOT_ONLY] 名称已存在。";
            case 201:
                return "[" + errorCode + " NET_DVR_OVER_MAX_ARRAY] 阵列达到上限。";
            case 202:
                return "[" + errorCode + " NET_DVR_OVER_MAX_VD] 虚拟磁盘达到上限。";
            case 203:
                return "[" + errorCode + " NET_DVR_VD_SLOT_EXCEED] 虚拟磁盘槽位已满。";
            case 204:
                return "[" + errorCode + " NET_DVR_PD_STATUS_INVALID] 重建阵列所需物理磁盘状态错误。";
            case 205:
                return "[" + errorCode + " NET_DVR_PD_BE_DEDICATE_SPARE] 重建阵列所需物理磁盘为指定热备。";
            case 206:
                return "[" + errorCode + " NET_DVR_PD_NOT_FREE] 重建阵列所需物理磁盘非空闲。";
            case 207:
                return "[" + errorCode + " NET_DVR_CANNOT_MIG2NEWMODE] 不能从当前的阵列类型迁移到新的阵列类型。";
            case 208:
                return "[" + errorCode + " NET_DVR_MIG_PAUSE] 迁移操作已暂停。";
            case 209:
                return "[" + errorCode + " NET_DVR_MIG_CANCEL] 正在执行的迁移操作已取消。";
            case 210:
                return "[" + errorCode + " NET_DVR_EXIST_VD] 阵列上存在虚拟磁盘,无法删除阵列。";
            case 211:
                return "[" + errorCode + " NET_DVR_TARGET_IN_LD_FUNCTIONAL] 对象物理磁盘为虚拟磁盘组成部分且工作正常。";
            case 212:
                return "[" + errorCode + " NET_DVR_HD_IS_ASSIGNED_ALREADY] 指定的物理磁盘被分配为虚拟磁盘。";
            case 213:
                return "[" + errorCode + " NET_DVR_INVALID_HD_COUNT] 物理磁盘数量与指定的RAID等级不匹配。";
            case 214:
                return "[" + errorCode + " NET_DVR_LD_IS_FUNCTIONAL] 阵列正常,无法重建。";
            case 215:
                return "[" + errorCode + " NET_DVR_BGA_RUNNING] 存在正在执行的后台任务。";
            case 216:
                return "[" + errorCode + " NET_DVR_LD_NO_ATAPI] 无法用ATAPI盘创建虚拟磁盘。";
            case 217:
                return "[" + errorCode + " NET_DVR_MIGRATION_NOT_NEED] 阵列无需迁移。";
            case 218:
                return "[" + errorCode + " NET_DVR_HD_TYPE_MISMATCH] 物理磁盘不属于同意类型。";
            case 219:
                return "[" + errorCode + " NET_DVR_NO_LD_IN_DG] 无虚拟磁盘,无法进行此项操作。";
            case 220:
                return "[" + errorCode + " NET_DVR_NO_ROOM_FOR_SPARE] 磁盘空间过小,无法被指定为热备盘。";
            case 221:
                return "[" + errorCode + " NET_DVR_SPARE_IS_IN_MULTI_DG] 磁盘已被分配为某阵列热备盘。";
            case 222:
                return "[" + errorCode + " NET_DVR_DG_HAS_MISSING_PD] 阵列缺少盘。";
            case 223:
                return "[" + errorCode + " NET_DVR_NAME_EMPTY] 名称为空。";
            case 224:
                return "[" + errorCode + " NET_DVR_INPUT_PARAM] 输入参数有误。";
            case 225:
                return "[" + errorCode + " NET_DVR_PD_NOT_AVAILABLE] 物理磁盘不可用。";
            case 226:
                return "[" + errorCode + " NET_DVR_ARRAY_NOT_AVAILABLE] 阵列不可用。";
            case 227:
                return "[" + errorCode + " NET_DVR_PD_COUNT] 物理磁盘数不正确。";
            case 228:
                return "[" + errorCode + " NET_DVR_VD_SMALL] 虚拟磁盘太小。";
            case 229:
                return "[" + errorCode + " NET_DVR_NO_EXIST] 不存在。";
            case 230:
                return "[" + errorCode + " NET_DVR_NOT_SUPPORT] 不支持该操作。";
            case 231:
                return "[" + errorCode + " NET_DVR_NOT_FUNCTIONAL] 阵列状态不是正常状态。";
            case 232:
                return "[" + errorCode + " NET_DVR_DEV_NODE_NOT_FOUND] 虚拟磁盘设备节点不存在。";
            case 233:
                return "[" + errorCode + " NET_DVR_SLOT_EXCEED] 槽位达到上限。";
            case 234:
                return "[" + errorCode + " NET_DVR_NO_VD_IN_ARRAY] 阵列上不存在虚拟磁盘。";
            case 235:
                return "[" + errorCode + " NET_DVR_VD_SLOT_INVALID] 虚拟磁盘槽位无效。";
            case 236:
                return "[" + errorCode + " NET_DVR_PD_NO_ENOUGH_SPACE] 所需物理磁盘空间不足。";
            case 237:
                return "[" + errorCode + " NET_DVR_ARRAY_NONFUNCTION] 只有处于正常状态的阵列才能进行迁移。";
            case 238:
                return "[" + errorCode + " NET_DVR_ARRAY_NO_ENOUGH_SPACE] 阵列空间不足。";
            case 239:
                return "[" + errorCode + " NET_DVR_STOPPING_SCANNING_ARRAY] 正在执行安全拔盘或重新扫描。";
            case 240:
                return "[" + errorCode + " NET_DVR_NOT_SUPPORT_16T] 不支持创建大于16T的阵列。";
            case 300:
                return "[" + errorCode + " NET_DVR_ID_ERROR] 配置ID不合理。";
            case 301:
                return "[" + errorCode + " NET_DVR_POLYGON_ERROR] 多边形不符合要求。";
            case 302:
                return "[" + errorCode + " NET_DVR_RULE_PARAM_ERROR] 规则参数不合理。";
            case 303:
                return "[" + errorCode + " NET_DVR_RULE_CFG_CONFLICT] 配置信息冲突。";
            case 304:
                return "[" + errorCode + " NET_DVR_CALIBRATE_NOT_READY] 当前没有标定信息。";
            case 305:
                return "[" + errorCode + " NET_DVR_CAMERA_DATA_ERROR] 摄像机参数不合理。";
            case 306:
                return "[" + errorCode + " NET_DVR_CALIBRATE_DATA_UNFIT] 长度不够倾斜,不利于标定。";
            case 307:
                return "[" + errorCode + " NET_DVR_CALIBRATE_DATA_CONFILICT] 标定出错,以为所有点共线或者位置太集中。";
            case 308:
                return "[" + errorCode + " NET_DVR_CALIBRATE_CALC_FAIL] 摄像机标定参数值计算失败。";
            case 309:
                return "[" + errorCode + " NET_DVR_CALIBRATE_LINE_OUT_RECT] 输入的样本标定线超出了样本外接矩形框。";
            case 310:
                return "[" + errorCode + " NET_DVR_ENTER_RULE_NOT_READY] 没有设置进入区域。";
            case 311:
                return "[" + errorCode + " NET_DVR_AID_RULE_NO_INCLUDE_LANE] 交通事件规则中没有包括车道(特值拥堵和逆行)。";
            case 312:
                return "[" + errorCode + " NET_DVR_LANE_NOT_READY] 当前没有设置车道。";
            case 313:
                return "[" + errorCode + " NET_DVR_RULE_INCLUDE_TWO_WAY] 事件规则中包含2种不同方向。";
            case 314:
                return "[" + errorCode + " NET_DVR_LANE_TPS_RULE_CONFLICT] 车道和数据规则冲突。";
            case 315:
                return "[" + errorCode + " NET_DVR_NOT_SUPPORT_EVENT_TYPE] 不支持的事件类型。";
            case 316:
                return "[" + errorCode + " NET_DVR_LANE_NO_WAY] 车道没有方向。";
            case 317:
                return "[" + errorCode + " NET_DVR_SIZE_FILTER_ERROR] 尺寸过滤框不合理。";
            case 318:
                return "[" + errorCode + " NET_DVR_LIB_FFL_NO_FACE] 特征点定位时输入的图像没有人脸。";
            case 319:
                return "[" + errorCode + " NET_DVR_LIB_FFL_IMG_TOO_SMALL] 特征点定位时输入的图像太小。";
            case 320:
                return "[" + errorCode + " NET_DVR_LIB_FD_IMG_NO_FACE] 单张图像人脸检测时输入的图像没有人脸。";
            case 321:
                return "[" + errorCode + " NET_DVR_LIB_FACE_TOO_SMALL] 建模时人脸太小。";
            case 322:
                return "[" + errorCode + " NET_DVR_LIB_FACE_QUALITY_TOO_BAD] 建模时人脸图像质量太差。";
            case 323:
                return "[" + errorCode + " NET_DVR_KEY_PARAM_ERR] 高级参数设置错误。";
            case 324:
                return "[" + errorCode + " NET_DVR_CALIBRATE_DATA_ERR] 标定样本数目错误,或数据值错误,或样本点超出地平线。";
            case 325:
                return "[" + errorCode + " NET_DVR_CALIBRATE_DISABLE_FAIL] 所配置规则不允许取消标定。";
            case 800:
                return "[" + errorCode + " NET_DVR_DEV_NET_OVERFLOW] 网络流量超过设备能力上限。";
            case 801:
                return "[" + errorCode + " NET_DVR_STATUS_RECORDFILE_WRITING_NOT_LOCK] 录像文件在录像,无法被锁定。";
            case 802:
                return "[" + errorCode + " NET_DVR_STATUS_CANT_FORMAT_LITTLE_DISK] 由于硬盘太小无法格式化。";
            case 901:
                return "[" + errorCode + " NET_ERR_WINCHAN_IDX] 开窗通道号错误。";
            case 902:
                return "[" + errorCode + " NET_ERR_WIN_LAYER] 窗口层数错误,单个屏幕上最多覆盖的窗口层数。";
            case 903:
                return "[" + errorCode + " NET_ERR_WIN_BLK_NUM] 窗口的块数错误,单个窗口可覆盖的屏幕个数。";
            case 904:
                return "[" + errorCode + " NET_ERR_OUTPUT_RESOLUTION] 输出分辨率错误。";
            case 905:
                return "[" + errorCode + " NET_ERR_LAYOUT] 布局号错误。";
            case 906:
                return "[" + errorCode + " NET_ERR_INPUT_RESOLUTION] 输入分辨率不支持。";
            case 907:
                return "[" + errorCode + " NET_ERR_SUBDEVICE_OFFLINE] 子设备不在线。";
            case 908:
                return "[" + errorCode + " NET_ERR_NO_DECODE_CHAN] 没有空闲解码通道。";
            case 909:
                return "[" + errorCode + " NET_ERR_MAX_WINDOW_ABILITY] 开窗能力上限。";
            case 910:
                return "[" + errorCode + " NET_ERR_ORDER_ERROR] 调用顺序有误。";
            case 911:
                return "[" + errorCode + " NET_ERR_PLAYING_PLAN] 正在执行预案。";
            case 912:
                return "[" + errorCode + " NET_ERR_DECODER_USED] 解码板正在使用。";
            case 401:
                return "[" + errorCode + " NET_DVR_RTSP_ERROR_NOENOUGHPRI] 无权限:服务器返回401时,转成这个错误码。";
            case 402:
                return "[" + errorCode + " NET_DVR_RTSP_ERROR_ALLOC_RESOURCE] 分配资源失败。";
            case 403:
                return "[" + errorCode + " NET_DVR_RTSP_ERROR_PARAMETER] 参数错误。";
            case 404:
                return "[" + errorCode + " NET_DVR_RTSP_ERROR_NO_URL] 指定的URL地址不存在:服务器返回404时,转成这个错误码。";
            case 406:
                return "[" + errorCode + " NET_DVR_RTSP_ERROR_FORCE_STOP] 用户中途强行退出。";
            case 407:
                return "[" + errorCode + " NET_DVR_RTSP_GETPORTFAILED] 获取RTSP端口错误。";
            case 410:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBERROR] RTSP DECRIBE交互错误。";
            case 411:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBESENDTIMEOUT] RTSP DECRIBE发送超时。";
            case 412:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBESENDERROR] RTSP DECRIBE发送失败。";
            case 413:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBERECVTIMEOUT] RTSP DECRIBE接收超时。";
            case 414:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBERECVDATALOST] RTSP DECRIBE接收数据错误。";
            case 415:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBERECVERROR] RTSP DECRIBE接收失败。";
            case 416:
                return "[" + errorCode + " NET_DVR_RTSP_DESCRIBESERVERERR] RTSP DECRIBE服务器返回401,501等错误。";
            case 420:
                return "[" + errorCode + " NET_DVR_RTSP_SETUPERROR] RTSP SETUP交互错误。";
            case 421:
                return "[" + errorCode + " NET_DVR_RTSP_SETUPSENDTIMEOUT] RTSP SETUP发送超时。";
            case 422:
                return "[" + errorCode + " NET_DVR_RTSP_SETUPSENDERROR] RTSP SETUP发送错误。";
            case 423:
                return "[" + errorCode + " NET_DVR_RTSP_SETUPRECVTIMEOUT] RTSP SETUP接收超时。";
            case 424:
                return "[" + errorCode + " NET_DVR_RTSP_SETUPRECVDATALOST] RTSP SETUP接收数据错误。";
            case 425:
                return "[" + errorCode + " NET_DVR_RTSP_SETUPRECVERROR] RTSP SETUP接收失败。";
            case 426:
                return "[" + errorCode + " NET_DVR_RTSP_OVER_MAX_CHAN] 设备超过最大连接数。";
            case 430:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYERROR] RTSP PLAY交互错误。";
            case 431:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYSENDTIMEOUT] RTSP PLAY发送超时。";
            case 432:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYSENDERROR] RTSP PLAY发送错误。";
            case 433:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYRECVTIMEOUT] RTSP PLAT接收超时。";
            case 434:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYRECVDATALOST] RTSP PLAY接收数据错误。";
            case 435:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYRECVERROR] RTSP PLAY接收失败。";
            case 436:
                return "[" + errorCode + " NET_DVR_RTSP_PLAYSERVERERR] RTSP PLAY设备返回错误状态。";
            case 440:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNERROR] RTSP TEARDOWN交互错误。";
            case 441:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNSENDTIMEOUT] RTSP TEARDOWN发送超时。";
            case 442:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNSENDERROR] RTSP TEARDOWN发送错误。";
            case 443:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNRECVTIMEOUT] RTSP TEARDOWN接收超时。";
            case 444:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNRECVDATALOST] RTSP TEARDOWN接收数据错误。";
            case 445:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNRECVERROR] RTSP TEARDOWN接收失败。";
            case 446:
                return "[" + errorCode + " NET_DVR_RTSP_TEARDOWNSERVERERR] RTSP TEARDOWN设备返回错误状态。";
            case 500:
                return "[" + errorCode + " NET_PLAYM4_NOERROR] 没有错误。";
            case 501:
                return "[" + errorCode + " NET_PLAYM4_PARA_OVER] 输入参数非法。";
            case 502:
                return "[" + errorCode + " NET_PLAYM4_ORDER_ERROR] 调用顺序不对。";
            case 503:
                return "[" + errorCode + " NET_PLAYM4_TIMER_ERROR] 多媒体时钟设置失败。";
            case 504:
                return "[" + errorCode + " NET_PLAYM4_DEC_VIDEO_ERROR] 视频解码失败。";
            case 505:
                return "[" + errorCode + " NET_PLAYM4_DEC_AUDIO_ERROR] 音频解码失败。";
            case 506:
                return "[" + errorCode + " NET_PLAYM4_ALLOC_MEMORY_ERROR] 分配内存失败。";
            case 507:
                return "[" + errorCode + " NET_PLAYM4_OPEN_FILE_ERROR] 文件操作失败。";
            case 508:
                return "[" + errorCode + " NET_PLAYM4_CREATE_OBJ_ERROR] 创建线程事件等失败。";
            case 509:
                return "[" + errorCode + " NET_PLAYM4_CREATE_DDRAW_ERROR] 创建directDraw失败。";
            case 510:
                return "[" + errorCode + " NET_PLAYM4_CREATE_OFFSCREEN_ERROR] 创建后端缓存失败。";
            case 511:
                return "[" + errorCode + " NET_PLAYM4_BUF_OVER] 缓冲区满,输入流失败。";
            case 512:
                return "[" + errorCode + " NET_PLAYM4_CREATE_SOUND_ERROR] 创建音频设备失败。";
            case 513:
                return "[" + errorCode + " NET_PLAYM4_SET_VOLUME_ERROR] 设置音量失败。";
            case 514:
                return "[" + errorCode + " NET_PLAYM4_SUPPORT_FILE_ONLY] 只能在播放文件时才能使用此接口。";
            case 515:
                return "[" + errorCode + " NET_PLAYM4_SUPPORT_STREAM_ONLY] 只能在播放流时才能使用此接口。";
            case 516:
                return "[" + errorCode + " NET_PLAYM4_SYS_NOT_SUPPORT] 系统不支持,解码器只能工作在Pentium";
            case 517:
                return "[" + errorCode + " NET_PLAYM4_FILEHEADER_UNKNOWN] 没有文件头。";
            case 518:
                return "[" + errorCode + " NET_PLAYM4_VERSION_INCORRECT] 解码器和编码器版本不对应。";
            case 519:
                return "[" + errorCode + " NET_PALYM4_INIT_DECODER_ERROR] 初始化解码器失败。";
            case 520:
                return "[" + errorCode + " NET_PLAYM4_CHECK_FILE_ERROR] 文件太短或码流无法识别。";
            case 521:
                return "[" + errorCode + " NET_PLAYM4_INIT_TIMER_ERROR] 初始化多媒体时钟失败。";
            case 522:
                return "[" + errorCode + " NET_PLAYM4_BLT_ERROR] 位拷贝失败。";
            case 523:
                return "[" + errorCode + " NET_PLAYM4_UPDATE_ERROR] 显示overlay失败。";
            case 524:
                return "[" + errorCode + " NET_PLAYM4_OPEN_FILE_ERROR_MULTI] 打开混合流文件失败。";
            case 525:
                return "[" + errorCode + " NET_PLAYM4_OPEN_FILE_ERROR_VIDEO] 打开视频流文件失败。";
            case 526:
                return "[" + errorCode + " NET_PLAYM4_JPEG_COMPRESS_ERROR] JPEG压缩错误。";
            case 527:
                return "[" + errorCode + " NET_PLAYM4_EXTRACT_NOT_SUPPORT] 不支持该文件版本。";
            case 528:
                return "[" + errorCode + " NET_PLAYM4_EXTRACT_DATA_ERROR] 提取文件数据失败。";
            case 678:
                return "[" + errorCode + " NET_QOS_ERR_SCHEDPARAMS_BAD_MINIMUM_INTERVAL] 预设的最小间隔错误。";
            case 679:
                return "[" + errorCode + " NET_QOS_ERR_SCHEDPARAMS_BAD_FRACTION] 预设分数错误。";
            case 680:
                return "[" + errorCode + " NET_QOS_ERR_SCHEDPARAMS_INVALID_BANDWIDTH] 预设的带宽值无效。";
            case 687:
                return "[" + errorCode + " NET_QOS_ERR_PACKET_TOO_BIG] 数据包太大。";
            case 688:
                return "[" + errorCode + " NET_QOS_ERR_PACKET_LENGTH] 数据包长度错误。";
            case 689:
                return "[" + errorCode + " NET_QOS_ERR_PACKET_VERSION] 数据包版本错误。";
            case 690:
                return "[" + errorCode + " NET_QOS_ERR_PACKET_UNKNOW] 未知数据包。";
            case 695:
                return "[" + errorCode + " NET_QOS_ERR_OUTOFMEM] 内存不足。";
            case 696:
                return "[" + errorCode + " NET_QOS_ERR_LIB_NOT_INITIALIZED] Lib库没有初始化。";
            case 697:
                return "[" + errorCode + " NET_QOS_ERR_SESSION_NOT_FOUND] 没有找到会话。";
            case 698:
                return "[" + errorCode + " NET_QOS_ERR_INVALID_ARGUMENTS] 参数无效。";
            case 699:
                return "[" + errorCode + " NET_QOS_ERROR] Qos 错误。";
            case 700:
                return "[" + errorCode + " NET_QOS_OK] 没有错误。";
            default:
                return "[" + errorCode + " NET_???_??] 未知错误。";
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK
                && event.getRepeatCount() == 0) {
            finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


    private void initView() {
        iv_back = (ImageView) findViewById(R.id.iv_back);
        Sur_Player = (SurfaceView) findViewById(R.id.Sur_Player);
        tv_num1 = (TextView) findViewById(R.id.tv_num1);
        tv_num2 = (TextView) findViewById(R.id.tv_num2);
        tv_num3 = (TextView) findViewById(R.id.tv_num3);
        tv_num4 = (TextView) findViewById(R.id.tv_num4);
        iv_go_back = (ImageView) findViewById(R.id.iv_go_back);
        iv_start_stop = (ImageView) findViewById(R.id.iv_start_stop);
        iv_go_forward = (ImageView) findViewById(R.id.iv_go_forward);
        tv_left = (ImageView) findViewById(R.id.tv_left);
        tv_right = (ImageView) findViewById(R.id.tv_right);
        tv_up = (ImageView) findViewById(R.id.tv_up);
        tv_down = (ImageView) findViewById(R.id.tv_down);
        tv_play_right = (TextView) findViewById(R.id.tv_play_right);
        ll_up_down = (LinearLayout) findViewById(R.id.ll_up_down);
        lv_chose_video = (MyListView) findViewById(R.id.lv_chose_video);

        tv_num1.setTextColor(Color.rgb(0, 255, 0));//设置通道按钮选中状态颜色

        //设置点击事件
        iv_back.setOnClickListener(this);
        tv_num1.setOnClickListener(this);
        tv_num2.setOnClickListener(this);
        tv_num3.setOnClickListener(this);
        tv_num4.setOnClickListener(this);
        iv_go_back.setOnClickListener(this);
        iv_start_stop.setOnClickListener(this);
        iv_go_forward.setOnClickListener(this);
        tv_up.setOnClickListener(this);
        tv_down.setOnClickListener(this);
        tv_left.setOnClickListener(this);
        tv_right.setOnClickListener(this);
        tv_play_right.setOnClickListener(this);

        getDataFromLastPage();


        videoLogin();//登录


        tv_play_right = (TextView) findViewById(R.id.tv_play_right);
        tv_play_right.setOnClickListener(this);
    }

    private void getDataFromLastPage() {

        Intent intent=getIntent();
        ip = intent.getStringExtra("IP");
        String sPort = intent.getStringExtra("port");
        if(!TextUtils.isEmpty(sPort)){
            port = Integer.parseInt(sPort);
        }
        username = intent.getStringExtra("username");
        psd = intent.getStringExtra("psd");
        String tdh = intent.getStringExtra("tdh");
        KLog.e("获取上个页面数据 IP:"+ip+"端口:"+port+"用户名"+username+"密码:"+psd+"通道:"+tdh);
        if(!"".equals(tdh)){
            int TDH = Integer.parseInt(tdh);
            m_iStartChan=TDH;
        }else{
            MyUtils.showToast(DemoActivity.this,"通道号不正确!");
        }

    }

    public static Boolean isPlaying=false;//默认没有播放
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_play_right:
                if(!isPlaying){
                    tv_play_right.setText("停止");
                    startVideoPreView();
                }else{
                    tv_play_right.setText("开启");
                    startVideoPreView();
                }
                isPlaying=!isPlaying;
                break;
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_num1:
                tv_num1.setTextColor(Color.rgb(0, 255, 0));
                break;
            case R.id.tv_num2:
                MyUtils.showToast(DemoActivity.this, "只有一个通道哦!");

                break;
            case R.id.tv_num3:
                MyUtils.showToast(DemoActivity.this, "只有一个通道哦!");

                break;
            case R.id.tv_num4:
                MyUtils.showToast(DemoActivity.this, "只有一个通道哦!");

                break;
            case R.id.iv_go_back://后退
                MyUtils.showToast(DemoActivity.this, "摄像头不包含此功能!");

                break;
            case R.id.iv_start_stop://暂停 开始
                MyUtils.showToast(DemoActivity.this, "摄像头不包含此功能!");

                break;
            case R.id.iv_go_forward://快进
                MyUtils.showToast(DemoActivity.this, "摄像头不包含此功能!");

                break;
            case R.id.tv_up://上
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on device first");
                    MyUtils.showToast(DemoActivity.this, "请先连接摄像头!");
                    return;
                }

//                if (m_iPlaybackID >= 0) {
//                    Log.i(TAG, "Please stop palyback first");
//                    return;
//                }
                PTZTest.Test_PTZControlUP(m_iPlayID);

                break;
            case R.id.tv_down://下
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on device first");
                    MyUtils.showToast(DemoActivity.this, "请先连接摄像头!");
                    return;
                }

//                if (m_iPlaybackID >= 0) {
//                    Log.i(TAG, "Please stop palyback first");
//                    return;
//                }
                PTZTest.Test_PTZControlDOWN(m_iPlayID);

                break;
            case R.id.tv_left://左
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on device first");
                    MyUtils.showToast(DemoActivity.this, "请先连接摄像头!");
                    return;
                }

//                if (m_iPlaybackID >= 0) {
//                    Log.i(TAG, "Please stop palyback first");
//                    return;
//                }
                PTZTest.Test_PTZControlLEFT(m_iPlayID);

                break;
            case R.id.tv_right://右
                if (m_iLogID < 0) {
                    Log.e(TAG, "please login on device first");
                    MyUtils.showToast(DemoActivity.this, "请先连接摄像头!");
                    return;
                }

//                if (m_iPlaybackID >= 0) {
//                    Log.i(TAG, "Please stop palyback first");
//                    return;
//                }
                PTZTest.Test_PTZControlRIGHT(m_iPlayID);

                break;
        }
    }


}
 
 
 
第二次进入这个页面播放ID获取的为0 ,这样的话就不是正确的ID无法播放,所以在查询过之后我替换了原
来sdk的播放的方法,从而解决了这个问题



版权声明:本文为flyingsnowtiger原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。