{"id":386,"date":"2013-04-30T16:19:48","date_gmt":"2013-04-30T23:19:48","guid":{"rendered":"http:\/\/192.168.1.2\/wordpress\/?p=386"},"modified":"2013-05-03T17:13:53","modified_gmt":"2013-05-04T00:13:53","slug":"android-remote-control-for-net-tv3","status":"publish","type":"post","link":"http:\/\/cywang.no-ip.org\/wordpress\/?p=386","title":{"rendered":"Android Remote Control for net-TV3"},"content":{"rendered":"<p>\n\tThis app uses wireless network to connect your PC and then sends commands to control your player software. Now, it only supports <a href=\"http:\/\/www.upmostgroup.com.tw\" target=\"_blank\">UPMOST<\/a> net-TV3 (network TV-BOX).\n<\/p>\n<p>\n\tDevelopment tool:\n<\/p>\n<ul>\n<li>\n\t\tServer: Embarcadero C++ Builder XE3\n\t<\/li>\n<li>\n\t\tClient: Eclipse with Android SDK\n\t<\/li>\n<li>\n\t\tTesting Platform: HTC Desire HD (Android 2.3.4)\n\t<\/li>\n<\/ul>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<!--more-->\n<\/p>\n<p>\n\t<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario.jpg\" style=\"font-size: 13px;\">\u200b<\/a>Scenario:<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario.jpg\" style=\"font-size: 13px;\"><img loading=\"lazy\" decoding=\"async\" alt=\"Scenario\" class=\"alignnone size-full wp-image-395\" height=\"566\" src=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario.jpg\" style=\"opacity: 0.9;\" width=\"1160\" srcset=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario.jpg 1160w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario-300x146.jpg 300w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario-1024x499.jpg 1024w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/Scenario-500x243.jpg 500w\" sizes=\"auto, (max-width: 1160px) 100vw, 1160px\" \/><\/a>\n<\/p>\n<p>\n\t<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/connection.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"connection\" class=\"alignnone size-full wp-image-388\" height=\"800\" src=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/connection.jpg\" width=\"480\" srcset=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/connection.jpg 480w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/connection-180x300.jpg 180w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a>\n<\/p>\n<p>\n\t<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/pad.jpg\" style=\"font-size: 13px;\"><img loading=\"lazy\" decoding=\"async\" alt=\"pad\" class=\"alignnone size-full wp-image-391\" height=\"800\" src=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/pad.jpg\" style=\"opacity: 0.9;\" width=\"480\" srcset=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/pad.jpg 480w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/pad-180x300.jpg 180w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a>\n<\/p>\n<p>\n\t<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/mute.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"800\" alt=\"mute\" class=\"alignnone size-full wp-image-389\" src=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/mute.jpg\" style=\"width: 240px; height: 400px;\" srcset=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/mute.jpg 480w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/mute-180x300.jpg 180w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a> <a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote.jpg\" style=\"font-size: 13px;\"><img loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"800\" alt=\"remote\" class=\"alignnone size-full wp-image-394\" src=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote.jpg\" style=\"width: 240px; height: 400px;\" srcset=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote.jpg 480w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote-180x300.jpg 180w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a>\n<\/p>\n<p>\n\tServer side:\n<\/p>\n<p>\n\t&nbsp;&nbsp;&nbsp;<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote_server.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"remote_server\" class=\"alignnone size-full wp-image-393\" height=\"430\" src=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote_server.jpg\" width=\"713\" srcset=\"http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote_server.jpg 713w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote_server-300x180.jpg 300w, http:\/\/cywang.no-ip.org\/wordpress\/wp-content\/uploads\/2013\/04\/remote_server-497x300.jpg 497w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/a>\n<\/p>\n<p>\n\tClient side partial source code:\n<\/p>\n<pre class=\"brush:java;\">\r\npackage com.dhd.remotecontrol;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.BufferedWriter;\r\nimport java.io.IOException;\r\nimport java.io.OutputStreamWriter;\r\nimport java.io.PrintWriter;\r\nimport java.net.InetAddress;\r\nimport java.net.NetworkInterface;\r\nimport java.net.Socket;\r\nimport java.net.SocketException;\r\nimport java.net.UnknownHostException;\r\nimport java.util.Enumeration;\r\nimport java.util.Vector;\r\n\r\nimport android.os.Bundle;\r\nimport android.app.Activity;\r\nimport android.util.Log;\r\nimport android.view.Menu;\r\nimport android.view.View;\r\nimport android.widget.AdapterView;\r\nimport android.widget.AdapterView.OnItemSelectedListener;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.Button;\r\nimport android.widget.EditText;\r\nimport android.widget.ImageButton;\r\nimport android.widget.ImageView;\r\nimport android.widget.Spinner;\r\nimport android.widget.TabHost;\r\nimport android.widget.TabHost.TabSpec;\r\nimport android.widget.TextView;\r\nimport android.widget.Toast;\r\n\r\npublic class MainActivity extends Activity \r\n{\r\n\t\r\n\tprivate Button Btn_Connection;\r\n\tprivate Spinner Spinner_ProcessList; \r\n\t\r\n\tprivate String[] lists= {&quot;net-TV 2012&quot;, &quot;AVerTV 3D&quot;};\r\n\t\r\n\tpublic EditText textView_IP;\r\n\tpublic EditText textView_Port;\r\n\tpublic Socket socket;\r\n\tpublic InetAddress serverAddr;\r\n\t\r\n\tpublic static String hostip;\r\n\tpublic String selectProcess;\r\n\t\r\n\t\r\n\tprivate Button Btn_1, Btn_2, Btn_3, Btn_4, Btn_5, Btn_6, Btn_7, Btn_8, Btn_9, Btn_0, Btn_100,\r\n\tBtn_last;\r\n\t\r\n\tprivate ImageButton  Btn_vol_up, Btn_vol_down, Btn_ch_up, Btn_ch_down, Btn_power, Btn_mute;\r\n\tprivate TextView textView_Channel;\r\n\t\r\n\tprivate TabHost tabHost;\r\n\tprivate TabSpec tabSpec;\r\n\t\r\n\tint currentChannel;\r\n\tint prevChannel;\r\n    \r\n    private String sendMessage;\r\n    \/\/private String connectInfo;\r\n    private String  info[];\r\n    private boolean connected; \r\n    private boolean hundredClicked; \r\n    private boolean muteClicked;\r\n    \r\n    private PrintWriter out;     \r\n    BufferedReader in;\r\n    Vector&lt;String&gt; channelVector = new Vector&lt;String&gt;();\r\n\t\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState)\r\n\t{\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.activity_main);\r\n\t\t\r\n\t\tsetViewComponent();\r\n\t}\r\n\r\n\t@Override\r\n\tpublic boolean onCreateOptionsMenu(Menu menu) \r\n\t{\r\n\t\t\/\/ Inflate the menu; this adds items to the action bar if it is present.\r\n\t\tgetMenuInflater().inflate(R.menu.main, menu);\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\t\r\n\tprivate void setViewComponent()\r\n\t{\r\n\t\t\/\/ TabHost Initializer\r\n\t\ttabHost = (TabHost)findViewById(R.id.tabHost);\r\n\t\ttabHost.setup();\r\n\t\t\r\n\t\ttabSpec = tabHost.newTabSpec(&quot;tag1&quot;);\r\n\t\ttabSpec.setContent(R.id.tab_connection);\r\n\t\ttabSpec.setIndicator(&quot;Connection&quot;, getResources().getDrawable(R.drawable.ic_launcher_wireless2));\r\n\t\ttabHost.addTab(tabSpec);\r\n\r\n\t\ttabSpec = tabHost.newTabSpec(&quot;tag2&quot;);\r\n\t\ttabSpec.setContent(R.id.tab_pad);\r\n\t\ttabSpec.setIndicator(&quot;Pad&quot;);\r\n\t\ttabHost.addTab(tabSpec);\r\n\t\t\r\n\t\ttabSpec = tabHost.newTabSpec(&quot;tag3&quot;);\r\n\t\ttabSpec.setContent(R.id.tab_vol_ch);\r\n\t\ttabSpec.setIndicator(&quot;Remote&quot;);\r\n\t\ttabHost.addTab(tabSpec);\r\n\t\t\r\n\t\t\r\n\t\t\/\/ Button and ImageButton\r\n\t\tBtn_Connection = (Button) this.findViewById(R.id.Btn_connect);\r\n\t\tBtn_1 = (Button)findViewById(R.id.Btn_1);\r\n\t\tBtn_2 = (Button)findViewById(R.id.Btn_2);\r\n\t\tBtn_3 = (Button)findViewById(R.id.Btn_3);\r\n\t\tBtn_4 = (Button)findViewById(R.id.Btn_4);\r\n\t\tBtn_5 = (Button)findViewById(R.id.Btn_5);\r\n\t\tBtn_6 = (Button)findViewById(R.id.Btn_6);\r\n\t\tBtn_7 = (Button)findViewById(R.id.Btn_7);\r\n\t\tBtn_8 = (Button)findViewById(R.id.Btn_8);\r\n\t\tBtn_9 = (Button)findViewById(R.id.Btn_9);\r\n\t\tBtn_0 = (Button)findViewById(R.id.Btn_0);\r\n\t\tBtn_100 = (Button)findViewById(R.id.Btn_100);\r\n\t\tBtn_last = (Button)findViewById(R.id.Btn_Last);\r\n\t\t\r\n\t\tBtn_power = (ImageButton)findViewById(R.id.imageBtn_Power);\r\n\t\tBtn_mute = (ImageButton)findViewById(R.id.imageBtn_Mute);\r\n\t\tBtn_vol_up = (ImageButton)findViewById(R.id.imageBtn_Vol_Up);\r\n\t\tBtn_vol_down = (ImageButton)findViewById(R.id.imageBtn_Vol_Down);\r\n\t\tBtn_ch_up = (ImageButton)findViewById(R.id.imageBtn_Ch_Up);\r\n\t\tBtn_ch_down = (ImageButton)findViewById(R.id.imageBtn_Ch_Down);\r\n\t\t\r\n\t\t\r\n\t\t\/\/TextView\r\n\t\ttextView_IP = (EditText)findViewById(R.id.editText_IP);\r\n\t\ttextView_Port = (EditText)findViewById(R.id.editText_Port);\r\n\t\ttextView_Channel = (TextView)findViewById(R.id.textView_CurrentChannel); \r\n\t\t\r\n\t\t\r\n\t\t\/\/ Initialize Spinner Context\r\n\t\tSpinner_ProcessList = (Spinner) this.findViewById(R.id.spinner_ProcessList);\r\n\t\t\r\n\t\tArrayAdapter&lt;String&gt; item = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_spinner_dropdown_item,lists); \r\n\t\tSpinner_ProcessList.setAdapter(item); \r\n\t\tSpinner_ProcessList.setOnItemSelectedListener(new SpinnerSelectedListener());\r\n\t\tselectProcess = lists[0];\t\/\/Default\r\n\t\t\t\t\r\n\t\ttry\r\n\t\t{\r\n\t\t\thostip = getLocalIpAddress();\r\n\t\t\ttextView_IP.setText(hostip.subSequence(0, hostip.lastIndexOf(&quot;.&quot;)+1));\r\n\t\t\ttextView_Port.setText(&quot;7788&quot;);\r\n\t\t}\r\n\t\tcatch(Exception e1)\r\n\t\t{\r\n\t\t\tString connectInfo = &quot;Connection Fails. Please set your remote ip\/port again.&quot;;\r\n\t\t\tToast.makeText(this, connectInfo, Toast.LENGTH_LONG).show();\r\n\t\t}\t\r\n\t\t\r\n\t\t\r\n\t\t\/\/Variable Initialization\r\n\t\tsendMessage = &quot;&quot;;\r\n\t\tcurrentChannel = -1;\r\n\t\tprevChannel = -1;\r\n\t\tconnected = false;\r\n\t\thundredClicked = false;\r\n\t\tmuteClicked = false;\r\n\t\tinfo = new String[3];\r\n\t\tinfo[2] = selectProcess;\r\n\t\t\r\n\t\t\/\/ Button Listener\r\n\t\tBtn_Connection.setOnClickListener(Btn_ConnectionOnClick);\r\n\t\tBtn_1.setOnClickListener(Btn_1OnClick);\r\n\t\tBtn_2.setOnClickListener(Btn_2OnClick);\r\n\t\tBtn_3.setOnClickListener(Btn_3OnClick);\r\n\t\tBtn_4.setOnClickListener(Btn_4OnClick);\r\n\t\tBtn_5.setOnClickListener(Btn_5OnClick);\r\n\t\tBtn_6.setOnClickListener(Btn_6OnClick);\r\n\t\tBtn_7.setOnClickListener(Btn_7OnClick);\r\n\t\tBtn_8.setOnClickListener(Btn_8OnClick);\r\n\t\tBtn_9.setOnClickListener(Btn_9OnClick);\r\n\t\tBtn_0.setOnClickListener(Btn_0OnClick);\r\n\t\tBtn_100.setOnClickListener(Btn_100OnClick);\r\n\t\tBtn_last.setOnClickListener(Btn_lastOnClick);\r\n\t\t\r\n\t\tBtn_power.setOnClickListener(Btn_powerOnClick);\r\n\t\tBtn_mute.setOnClickListener(Btn_muteOnClick);\r\n\t\tBtn_vol_up.setOnClickListener(Btn_vol_upOnClick);\r\n\t\tBtn_vol_down.setOnClickListener(Btn_vol_downOnClick);\r\n\t\tBtn_ch_up.setOnClickListener(Btn_ch_upOnClick);\r\n\t\tBtn_ch_down.setOnClickListener(Btn_ch_downOnClick);\r\n\t}\r\n\tprivate void setChannel(String channel)\r\n\t{\r\n\t\tsendMessage += channel; \r\n    \ttextView_Channel.setText(&quot;Channel:&quot; + sendMessage);\r\n\t\ttry \r\n\t\t{\r\n\t\t\tif(sendMessage.length() == 2 &amp;&amp; !sendMessage.substring(0, 1).equals(&quot;+&quot;))\r\n\t\t\t{\r\n\t\t\t\tchannelVector.add(sendMessage);\r\n\t\t\t\tcurrentChannel = Integer.parseInt(sendMessage);\r\n\t\t\t\tout = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);\r\n\t\t\t\tout.println(info[2]+&quot;,&quot;+sendMessage);\r\n\t\t\t\tout.flush();\r\n\t\t\t\tsendMessage = &quot;&quot;;\r\n\t\t\t}\r\n\t\t\telse if(sendMessage.length() == 3 &amp;&amp; sendMessage.substring(0, 1).equals(&quot;+&quot;))\r\n\t\t\t{\r\n\t\t\t\tString hundChannel = &quot;&quot;;\r\n\t\t\t\thundChannel = &quot;1&quot; + sendMessage.substring(1,3);\r\n\t\t\t\tchannelVector.add(sendMessage);\r\n\t\t\t\tcurrentChannel = Integer.parseInt(hundChannel);\r\n\t\t\t\tout = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);\r\n\t\t\t\tout.println(info[2]+&quot;,&quot;+sendMessage);\r\n\t\t\t\tout.flush();\r\n\t\t\t\tsendMessage = &quot;&quot;;\r\n\t\t\t\thundredClicked = false;\r\n\t\t\t}\r\n\t\t} \r\n\t\tcatch (IOException e) \r\n\t\t{\r\n\t\t\t\r\n\t\t\te.printStackTrace();\r\n\t\t}  \r\n\t}\r\n\tprivate Button.OnClickListener Btn_1OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;1&quot;);    \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_2OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;2&quot;);     \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_3OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;3&quot;);        \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_4OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;4&quot;);      \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_5OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;5&quot;);      \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_6OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;6&quot;);      \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_7OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;7&quot;);      \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_8OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;8&quot;);      \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_9OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;9&quot;);      \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_0OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\t\tsetChannel(&quot;0&quot;);     \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_100OnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n        \t\tif(!hundredClicked &amp;&amp; sendMessage.length() == 0)\r\n        \t\t{\r\n\t            \tsendMessage += &quot;+&quot;; \r\n\t            \ttextView_Channel.setText(&quot;Channel:&quot; + sendMessage);\r\n\t            \thundredClicked = true;\r\n        \t\t}\r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_lastOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\ttry \r\n\t\t\t{\t\r\n\t\t\t\tif(connected)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(channelVector.size() &gt;= 2)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsendMessage = channelVector.get(channelVector.size()-2).toString(); \r\n\t\t\t\t\t\ttextView_Channel.setText(&quot;Channel:&quot; + sendMessage);  \r\n\t\t\t\t\t\tif(!sendMessage.substring(0, 1).equals(&quot;+&quot;))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tchannelVector.add(sendMessage);\r\n\t\t\t\t\t\t\tcurrentChannel = Integer.parseInt(sendMessage);\r\n\t\t\t\t\t\t\tout = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);\r\n\t\t\t\t\t\t\tout.println(info[2]+&quot;,&quot;+sendMessage);\r\n\t\t\t\t\t\t\tout.flush();\r\n\t\t\t\t\t\t\tsendMessage = &quot;&quot;;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if(sendMessage.length() == 3 &amp;&amp; sendMessage.substring(0, 1).equals(&quot;+&quot;))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tString hundChannel = &quot;&quot;;\r\n\t\t\t\t\t\t\thundChannel = &quot;1&quot; + sendMessage.substring(1,3);\r\n\t\t\t\t\t\t\tchannelVector.add(sendMessage);\r\n\t\t\t\t\t\t\tcurrentChannel = Integer.parseInt(hundChannel);\r\n\t\t\t\t\t\t\tout = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);\r\n\t\t\t\t\t\t\tout.println(info[2]+&quot;,&quot;+sendMessage);\r\n\t\t\t\t\t\t\tout.flush();\r\n\t\t\t\t\t\t\tsendMessage = &quot;&quot;;\r\n\t\t\t\t\t\t\thundredClicked = false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tout = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);\r\n\t\t\t\t\t\tout.println(info[2]+&quot;,L&quot;);\r\n\t\t\t\t\t\tout.flush();\r\n\t\t\t\t\t\tsendMessage = &quot;&quot;;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} \r\n\t\t\tcatch (IOException e) \r\n\t\t\t{\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}    \r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate void sendCommand(String cmd)\r\n\t{\r\n\t\tif(connected)\r\n\t\t{\r\n\t\t\ttry \r\n\t\t\t{\t\t\r\n\t\t\t\tout = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);\r\n\t\t\t\tout.println(info[2] + &quot;,&quot; + cmd);\r\n\t\t\t\tout.flush();\t\t\r\n\t\t\t} \r\n\t\t\tcatch (IOException e) \r\n\t\t\t{\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tprivate Button.OnClickListener Btn_powerOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tsendCommand(&quot;CMD.POWERONOFF&quot;);  \t\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_muteOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(connected)\r\n        \t{\r\n\t\t\r\n\t\t\t\tif(muteClicked)\r\n\t\t\t\t{\r\n\t\t\t\t\tBtn_mute.setImageResource(R.drawable.ic_launcher_mute); \/\/un-mute\r\n\t\t\t\t\tmuteClicked = !muteClicked;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tBtn_mute.setImageResource(R.drawable.ic_launcher_mute2);\r\n\t\t\t\t\tmuteClicked = !muteClicked;\r\n\t\t\t\t}\r\n\t\t\t\tsendCommand(&quot;CMD.MUTE&quot;);  \t  \r\n        \t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_vol_upOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tsendCommand(&quot;CMD.VOLUP&quot;); \r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_vol_downOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tsendCommand(&quot;CMD.VOLDOWN&quot;); \r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_ch_upOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tsendCommand(&quot;CMD.CHNEXT&quot;); \r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_ch_downOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tsendCommand(&quot;CMD.CHBACK&quot;); \r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate Button.OnClickListener Btn_ConnectionOnClick = new Button.OnClickListener()\r\n\t{\r\n\t\tpublic void onClick(View v)\r\n\t\t{\r\n\t\t\tif(Btn_Connection.getText().toString().equals(&quot;Connect&quot;))\r\n\t\t\t{\t\r\n\t\t\t\ttry \r\n\t\t\t\t{\r\n\t\t\t\t\tserverAddr = InetAddress.getByName(textView_IP.getText().toString());\r\n\t\t\t\t\ttry \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsocket = new Socket(serverAddr, Integer.parseInt(textView_Port.getText().toString()));\r\n\t\t\t\t\t\tconnected = true;\r\n\t\t\t\t\t\tBtn_Connection.setText(&quot;Disconnect&quot;);\r\n\r\n\t\t\t\t\t\tinfo[0] = textView_IP.getText().toString();\r\n\t\t\t\t\t\tinfo[1] = textView_Port.getText().toString();\r\n\t\t\t\t\t\tView mView = tabHost.getTabWidget().getChildAt(0);\r\n\t\t\t\t\t\tImageView imageView = (ImageView)mView.findViewById(android.R.id.icon);\r\n\t\t\t\t\t\timageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher_connected)); \r\n\t\t\t\t\r\n\t\t\t\t\t\ttabHost.setCurrentTab(1);\r\n\t\t\t\t\t} \r\n\t\t\t\t\tcatch (NumberFormatException e) \r\n\t\t\t\t\t{\t\t\r\n\t\t\t\t\t\te.printStackTrace();\t\t\t\t\t\r\n\t\t\t\t\t\tToast.makeText(MainActivity.this, &quot;Connection Failed!&quot;, Toast.LENGTH_LONG).show();\t\t\t\t\r\n\t\t\t\t\t\tDisconnection();\r\n\t\t\t\t\t} \r\n\t\t\t\t\tcatch (IOException e) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t\t\tToast.makeText(MainActivity.this, &quot;Connection Failed!&quot;, Toast.LENGTH_LONG).show();\r\n\t\t\t\t\t\tDisconnection();\r\n\t\t\t\t\t}\r\n\t\t\t\t} \r\n\t\t\t\tcatch (UnknownHostException e) \r\n\t\t\t\t{\t\r\n\t\t\t\t\te.printStackTrace();\t\r\n\t\t\t\t\tToast.makeText(MainActivity.this, &quot;Connection Failed!&quot;, Toast.LENGTH_LONG).show();\r\n\t\t\t\t\tDisconnection();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if(Btn_Connection.getText().toString().equals(&quot;Disconnect&quot;))\r\n\t\t\t{\r\n\t\t\t\tBtn_Connection.setText(&quot;Connect&quot;);\r\n\t\t\t\ttry \r\n\t\t\t\t{\r\n\t\t\t\t\tsocket.close();\r\n\t\t\t\t\tDisconnection();\r\n\t\t\t\t} \r\n\t\t\t\tcatch (IOException e) \r\n\t\t\t\t{\r\n\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t\tconnected = false;\r\n\t\t\t\t}\r\n\t\t\t} \r\n\t\t}\r\n\t};\r\n\t\r\n\tprivate void Disconnection()\r\n\t{\r\n\t\tconnected = false;\t\r\n\t\tView mView = tabHost.getTabWidget().getChildAt(0);\r\n\t\tImageView imageView = (ImageView)mView.findViewById(android.R.id.icon);\r\n\t\timageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher_wireless2)); \r\n\t}\r\n\t\r\n\tclass SpinnerSelectedListener implements OnItemSelectedListener\r\n\t{\r\n\t\tpublic void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2,  long arg3) \r\n\t\t{  \r\n\t\t\tselectProcess = lists[arg2];\r\n\t\t\tinfo[2] = selectProcess; \r\n\t\t}  \r\n\t\t \r\n\t\tpublic void onNothingSelected(AdapterView&lt;?&gt; arg0) \r\n\t\t{\r\n\t\t\tselectProcess = lists[0]; \r\n\t\t\tinfo[2] = selectProcess;\r\n\t\t}\r\n\r\n\t}\r\n\t\r\n\tpublic String getLocalIpAddress() \r\n\t{     \r\n        try \r\n        {     \r\n            for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) \r\n            {     \r\n                NetworkInterface intf = en.nextElement();     \r\n                for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf     \r\n                        .getInetAddresses(); enumIpAddr.hasMoreElements();) \r\n                {     \r\n                    InetAddress inetAddress = enumIpAddr.nextElement();     \r\n                    if (!inetAddress.isLoopbackAddress()) \r\n                    {     \r\n                        return inetAddress.getHostAddress().toString();     \r\n                    }     \r\n                }     \r\n            }     \r\n        } \r\n        catch (SocketException ex) \r\n        {     \r\n            Log.e(&quot;WifiPreference IpAddress&quot;, ex.toString());     \r\n        }     \r\n        return null;     \r\n    }  \r\n\t\r\n}\r\n<\/pre>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\tServer side source code:\n<\/p>\n<pre class=\"brush:cpp;\">\r\n\/\/---------------------------------------------------------------------------\r\n\r\n#include &lt;vcl.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;winsock2.h&gt;\r\n#include &lt;vector&gt;\r\n#include &lt;algorithm&gt;\r\n\r\n#pragma hdrstop\r\n\r\n#include &quot;main.h&quot;\r\n\r\n\/\/---------------------------------------------------------------------------\r\n#pragma package(smart_init)\r\n#pragma resource &quot;*.dfm&quot;\r\nTForm_RemoteControl *Form_RemoteControl;\r\nusing namespace std;\r\n\r\nTInitCommonControlsEx ICC;\r\nHWND hIpEdit_ServerIP;\r\nint iServerIP, iServerPort;\r\nAnsiString strServerIP;\r\n\r\nTListItem *LogItem;\r\n\r\nvector &lt;AnsiString&gt; clientList;\r\nint iMuteCount = 0;\r\nAnsiString receiveMessage;\t\/\/[ProcessName], [Command]\r\n\/\/---------------------------------------------------------------------------\r\n__fastcall TForm_RemoteControl::TForm_RemoteControl(TComponent* Owner)\r\n\t: TForm(Owner)\r\n{\r\n}\r\n\/\/---------------------------------------------------------------------------\r\nvoid __fastcall TForm_RemoteControl::FormCreate(TObject *Sender)\r\n{\r\n\tICC.dwSize = sizeof(TInitCommonControlsEx);\r\n\tICC.dwICC = ICC_INTERNET_CLASSES;\r\n\tif(!InitCommonControlsEx(&amp;ICC))\r\n\t\treturn;\r\n\r\n\tstrServerIP = IdIPWatch_Server-&gt;LocalIP();\r\n\thIpEdit_ServerIP =CreateWindow(WC_IPADDRESS,NULL,WS_CHILD|WS_VISIBLE,95,13,140,20,Panel_Network-&gt;Handle,0,HInstance,NULL);\r\n\tiServerIP=ntohl(inet_addr(strServerIP.c_str()));\r\n\tSendMessage(hIpEdit_ServerIP,IPM_SETADDRESS,0,iServerIP);\r\n\r\n\tiServerPort = Edit_LocalPort-&gt;Text.ToInt();\r\n\r\n}\r\n\/\/---------------------------------------------------------------------------\r\n\r\nvoid __fastcall TForm_RemoteControl::ToolButton_ConnectionClick(TObject *Sender)\r\n{\r\n\r\n\tif(ToolButton_Connection-&gt;ImageIndex == 0)\t\/\/connection\r\n\t{\r\n\t\tToolButton_Connection-&gt;ImageIndex = 1;\r\n\t\tToolButton_Connection-&gt;Caption = &quot;      Disconnect      &quot;;\r\n\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Server Online&quot;);\r\n\r\n\r\n\t\tIdTCPServer_Remote-&gt;DefaultPort = iServerPort;\r\n\t\tIdTCPServer_Remote-&gt;Active = true;\r\n\r\n\t}\r\n\telse if(ToolButton_Connection-&gt;ImageIndex == 1)\r\n\t{\r\n\t\tToolButton_Connection-&gt;ImageIndex = 0;\r\n\t\tToolButton_Connection-&gt;Caption = &quot;       Connect       &quot;;\r\n\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Server Offline&quot;);\r\n\t\tIdTCPServer_Remote-&gt;Active = false;\r\n\t}\r\n}\r\n\/\/---------------------------------------------------------------------------\r\n\r\nvoid __fastcall TForm_RemoteControl::ChangeChannel(AnsiString strProcess, char *key)\r\n{\r\n    \/\/http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd375731(v=vs.85).aspx\r\n\tApplication-&gt;ProcessMessages();\r\n\tHWND netTV = FindWindow(NULL,strProcess.c_str());\r\n\tif (ShowWindow(netTV,SW_SHOWNORMAL))\r\n\t{\r\n\t\tApplication-&gt;ProcessMessages();\r\n\r\n\t\tHWND hFrgWnd = ::GetForegroundWindow();\r\n\t\tAttachThreadInput( GetWindowThreadProcessId(hFrgWnd, NULL), GetCurrentThreadId(), TRUE );\r\n\t\t::SetForegroundWindow(netTV);\r\n\t\t::BringWindowToTop(netTV);\r\n\r\n\t\tfor(int i=0;i&lt;strlen(key);i++)\r\n\t\t{\r\n\t\t\tkeybd_event(key[i], 0, 0, 0);\r\n\r\n\t\t\tint iStart = GetTickCount();\r\n\t\t\twhile (GetTickCount() - iStart &lt;= 200)\r\n\t\t\t\tApplication-&gt;ProcessMessages();\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif(key[0] == 0x58)\r\n\t\t{\r\n\t\t\tWinExec(&quot;C:\\\\Program Files (x86)\\\\net-TV\\\\net-TV 2012\\\\net-TV 2012.exe&quot;,SW_SHOW);\r\n\t\t}\r\n\t\telse\r\n\t\t\tShowMessage(&quot;Open &quot; + strProcess + &quot; first!&quot;);\r\n\t}\r\n}\r\n\/\/---------------------------------------------------------------------------\r\n\r\nvoid __fastcall TForm_RemoteControl::IdTCPServer_RemoteExecute(TIdContext *AContext)\r\n{\r\n\tAnsiString cmd = AContext-&gt;Connection-&gt;IOHandler-&gt;ReadLn().Trim();\r\n\tTStringList *msgList = new TStringList();\r\n\tTSysCharSet sepChars;\r\n\r\n\tsepChars = TSysCharSet() &lt;&lt; &#39;,&#39;;\r\n\tExtractStrings(sepChars, sepChars,  WideString(cmd).c_bstr(), msgList);\r\n\tchar *keyValue = new char[msgList->Strings[1].Length()];\r\n\tif(msgList-&gt;Strings[1].Pos(&quot;CMD&quot;) == 0)\r\n\t{\r\n\t\tif(msgList-&gt;Strings[1].SubString(1,1) != \"+\" &amp;&amp; msgList->Strings[1].Length() &gt;0)\r\n\t\t{\r\n\t\t\tfor(int i=0;i&lt;msgList-&gt;Strings[1].Length();i++)\r\n\t\t\t\tif(msgList-&gt;Strings[1].SubString(i+1,1).ToInt() >= 0 &amp;&amp; msgList->Strings[1].SubString(i+1,1).ToInt() &lt;=9)\r\n\t\t\t\t\tkeyValue[i] = msgList->Strings[1].SubString(i+1,1).ToInt()+0x30;\r\n\t\t}\r\n\t\tif(msgList-&gt;Strings[1].SubString(1,1) == \"+\" &amp;&amp; msgList->Strings[1].Length() &gt;0)\r\n\t\t{\r\n\t\t\tkeyValue[0] = VK_ADD;\r\n\t\t\tfor(int i=1;i&lt;msgList-&gt;Strings[1].Length();i++)\r\n\t\t\t\tkeyValue[i] = msgList->Strings[1].SubString(i+1,1).ToInt()+0x30;\r\n\r\n\t\t}\r\n\r\n\t\tif(keyValue[0] != VK_ADD)\r\n\t\t{\r\n\t\t\tif(keyValue[0] >= '0' &amp;&amp; keyValue[0]<='9' &amp;&amp; keyValue[1]>='0' &amp;&amp; keyValue[1]&lt;=&#39;9&#39;)\r\n\t\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\t\t}\r\n\t\telse if(keyValue[0] == VK_ADD)\r\n\t\t{\r\n\t\t\tif(keyValue[1] >= '0' &amp;&amp; keyValue[1]<='9' &amp;&amp; keyValue[2]>='0' &amp;&amp; keyValue[2]&lt;=&#39;9&#39;)\r\n\t\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\t\t}\r\n\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Channel: &quot; + msgList-&gt;Strings[1]);\r\n\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tAnsiString sysCMD = msgList-&gt;Strings[1].SubString(5,msgList->Strings[1].Length()-4);\r\n\t\tif(sysCMD == &quot;POWERONOFF&quot;)\r\n\t\t{\r\n\t\t\tkeyValue[0] = 0x58;   \/\/ X\r\n\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\r\n\t\t\tApplication-&gt;ProcessMessages();\r\n\t\t\tAnsiString strProcessName = msgList-&gt;Strings[0];\r\n\t\t\tHWND netTV = FindWindow(NULL,strProcessName.c_str());\r\n\t\t\tif (ShowWindow(netTV,SW_SHOWNORMAL))\r\n\t\t\t{\r\n\t\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Power Off&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Power On&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n            }\r\n\t\t}\r\n\r\n\t\tif(sysCMD == &quot;MUTE&quot;)\r\n\t\t{\r\n\t\t\tkeyValue[0] = 0x4D;\t\/\/ M\r\n\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\r\n\t\t\tif (iMuteCount%2 == 0)\r\n\t\t\t{\r\n\t\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Mute&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\t\t\t\tiMuteCount++;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Unmute&quot;);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\t\t\t\tiMuteCount++;\r\n            }\r\n\t\t}\r\n\r\n\t\tif(sysCMD == &quot;VOLUP&quot;)\r\n\t\t{\r\n\t\t\tkeyValue[0] = VK_RIGHT;\t\/\/ -&gt;\r\n\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\r\n\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Vol Up&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\r\n\t\t}\r\n\r\n\t\tif(sysCMD == &quot;VOLDOWN&quot;)\r\n\t\t{\r\n\t\t\tkeyValue[0] = VK_LEFT;\t\/\/ &lt;-\r\n\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\r\n\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Vol Down&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\r\n\t\t}\r\n\r\n\t\tif(sysCMD == &quot;CHNEXT&quot;)\r\n\t\t{\r\n\t\t\tkeyValue[0] = VK_UP;\t\/\/ -&gt;\r\n\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\r\n\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Vol Up&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\r\n\t\t}\r\n\r\n\t\tif(sysCMD == &quot;CHBACK&quot;)\r\n\t\t{\r\n\t\t\tkeyValue[0] = VK_DOWN;\t\/\/ &lt;-\r\n\t\t\tChangeChannel(msgList-&gt;Strings[0], keyValue);\r\n\r\n\t\t\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\t\t\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(&quot;Vol Down&quot;);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n\t\t\tLogItem-&gt;SubItems-&gt;Add(msgList-&gt;Strings[0]);\r\n\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\/\/---------------------------------------------------------------------------\r\nvoid __fastcall TForm_RemoteControl::IdTCPServer_RemoteConnect(TIdContext *AContext)\r\n{\r\n\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\tLogItem-&gt;SubItems-&gt;Add(&quot;Connect Request&quot;);\r\n\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n}\r\n\/\/---------------------------------------------------------------------------\r\n\r\nvoid __fastcall TForm_RemoteControl::IdTCPServer_RemoteDisconnect(TIdContext *AContext)\r\n{\r\n\tLogItem=ListView_Log-&gt;Items-&gt;Insert(0);\r\n\tLogItem-&gt;Caption=Now().CurrentTime().FormatString(&quot;hh:nn:ss&quot;);\r\n\tLogItem-&gt;SubItems-&gt;Add(&quot;Client Disconnected&quot;);\r\n\tLogItem-&gt;SubItems-&gt;Add(AContext-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP);\r\n}\r\n\/\/---------------------------------------------------------------------------\r\n<\/pre>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This app uses wireless network to connect your PC and then sends commands to control your player software. Now, it only supports UPMOST net-TV3 (network TV-BOX). Development tool: Server: Embarcadero C++ Builder XE3 Client: Eclipse with Android SDK Testing Platform: &hellip; <a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=386\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[8,7,3],"tags":[],"class_list":["post-386","post","type-post","status-publish","format-standard","hentry","category-android-development","category-cc","category-programming"],"_links":{"self":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=386"}],"version-history":[{"count":8,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/386\/revisions"}],"predecessor-version":[{"id":398,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/386\/revisions\/398"}],"wp:attachment":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=386"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}