From: <kro...@us...> - 2010-11-25 19:47:04
|
Revision: 3981 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3981&view=rev Author: kroko_koenig Date: 2010-11-25 19:46:56 +0000 (Thu, 25 Nov 2010) Log Message: ----------- playnow / playlist support Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/icon.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playingnow.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/remote.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java trunk/plugins/AndroidRemote/Release/Android Server communication.docx trunk/plugins/AndroidRemote/Release/nowplaying.jpg trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs trunk/plugins/AndroidRemote/Server/AndroidRemote.suo Added Paths: ----------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/drawable/border.ico trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/list_item.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playnowlist.xml trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylistXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java trunk/plugins/AndroidRemote/Release/nowplayingList.jpg trunk/plugins/AndroidRemote/Server/AndroidRemote/favicon.ico Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/AndroidManifest.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -20,6 +20,7 @@ <activity android:name=".picturesfullscreen"></activity> <activity android:name=".setup"></activity> <activity android:name=".nowplaying"></activity> + <activity android:name=".nowplaylist"></activity> </application> <uses-sdk android:minSdkVersion="3" /> Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/gen/mediaportal/remote/R.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -14,76 +14,82 @@ public static final int accept_icon=0x7f020000; public static final int back=0x7f020001; public static final int back_icon=0x7f020002; - public static final int cdcover=0x7f020003; - public static final int close_icon=0x7f020004; - public static final int document=0x7f020005; - public static final int down_icon=0x7f020006; - public static final int folder=0x7f020007; - public static final int folderback=0x7f020008; - public static final int forward=0x7f020009; - public static final int icon=0x7f02000a; - public static final int music_logo=0x7f02000b; - public static final int next_icon=0x7f02000c; - public static final int nowplaying_logo=0x7f02000d; - public static final int pause=0x7f02000e; - public static final int picture=0x7f02000f; - public static final int pictures_logo=0x7f020010; - public static final int play=0x7f020011; - public static final int remote_logo=0x7f020012; - public static final int rewind=0x7f020013; - public static final int splash=0x7f020014; - public static final int stop=0x7f020015; - public static final int up_icon=0x7f020016; - public static final int videos_logo=0x7f020017; + public static final int border=0x7f020003; + public static final int cdcover=0x7f020004; + public static final int close_icon=0x7f020005; + public static final int document=0x7f020006; + public static final int down_icon=0x7f020007; + public static final int folder=0x7f020008; + public static final int folderback=0x7f020009; + public static final int forward=0x7f02000a; + public static final int icon=0x7f02000b; + public static final int music_logo=0x7f02000c; + public static final int next_icon=0x7f02000d; + public static final int nowplaying_logo=0x7f02000e; + public static final int pause=0x7f02000f; + public static final int picture=0x7f020010; + public static final int pictures_logo=0x7f020011; + public static final int play=0x7f020012; + public static final int remote_logo=0x7f020013; + public static final int rewind=0x7f020014; + public static final int splash=0x7f020015; + public static final int stop=0x7f020016; + public static final int up_icon=0x7f020017; + public static final int videos_logo=0x7f020018; } public static final class id { - public static final int GridView01=0x7f050009; - public static final int ImageView01=0x7f05000b; - public static final int LinearLayout01=0x7f05000c; - public static final int MainButton1=0x7f050003; - public static final int MainButton2=0x7f050004; - public static final int MainButton3=0x7f050005; - public static final int MainButton4=0x7f050006; - public static final int MainButton5=0x7f050007; - public static final int btnCancel=0x7f05001d; - public static final int btnDown=0x7f05001f; - public static final int btnLeft=0x7f050021; - public static final int btnOk=0x7f05001e; - public static final int btnReturn=0x7f05001c; - public static final int btnReturnSetup=0x7f050024; - public static final int btnRight=0x7f050020; - public static final int btnUp=0x7f05001b; - public static final int full_text=0x7f05000a; + public static final int GridView01=0x7f05000b; + public static final int ImageView01=0x7f05000d; + public static final int LinearLayout01=0x7f05000e; + public static final int ListView01=0x7f05001d; + public static final int MainButton1=0x7f050005; + public static final int MainButton2=0x7f050006; + public static final int MainButton3=0x7f050007; + public static final int MainButton4=0x7f050008; + public static final int MainButton5=0x7f050009; + public static final int TextView01=0x7f050003; + public static final int TextView02=0x7f050004; + public static final int btnCancel=0x7f050020; + public static final int btnDown=0x7f050022; + public static final int btnLeft=0x7f050024; + public static final int btnOk=0x7f050021; + public static final int btnReturn=0x7f05001f; + public static final int btnReturnSetup=0x7f050027; + public static final int btnRight=0x7f050023; + public static final int btnUp=0x7f05001e; + public static final int full_text=0x7f05000c; public static final int icon_image=0x7f050001; public static final int icon_text=0x7f050002; - public static final int now_album=0x7f05000e; - public static final int now_artist=0x7f050014; - public static final int now_cd=0x7f05000f; - public static final int now_list=0x7f05001a; - public static final int now_next=0x7f050019; - public static final int now_pause=0x7f050017; - public static final int now_play=0x7f050018; - public static final int now_playing=0x7f05000d; - public static final int now_playing_right=0x7f050012; - public static final int now_playing_t_left=0x7f050011; - public static final int now_prev=0x7f050015; - public static final int now_progress=0x7f050010; - public static final int now_stop=0x7f050016; - public static final int now_title=0x7f050013; - public static final int server_ip=0x7f050022; - public static final int server_port=0x7f050023; - public static final int widget0=0x7f050008; + public static final int now_album=0x7f050010; + public static final int now_artist=0x7f050016; + public static final int now_cd=0x7f050011; + public static final int now_list=0x7f05001c; + public static final int now_next=0x7f05001b; + public static final int now_pause=0x7f050019; + public static final int now_play=0x7f05001a; + public static final int now_playing=0x7f05000f; + public static final int now_playing_right=0x7f050014; + public static final int now_playing_t_left=0x7f050013; + public static final int now_prev=0x7f050017; + public static final int now_progress=0x7f050012; + public static final int now_stop=0x7f050018; + public static final int now_title=0x7f050015; + public static final int server_ip=0x7f050025; + public static final int server_port=0x7f050026; + public static final int widget0=0x7f05000a; public static final int widget44=0x7f050000; } public static final class layout { public static final int icon=0x7f030000; - public static final int main=0x7f030001; - public static final int pictures=0x7f030002; - public static final int picturesfullscreen=0x7f030003; - public static final int playingnow=0x7f030004; - public static final int remote=0x7f030005; - public static final int setup=0x7f030006; - public static final int splash=0x7f030007; + public static final int list_item=0x7f030001; + public static final int main=0x7f030002; + public static final int pictures=0x7f030003; + public static final int picturesfullscreen=0x7f030004; + public static final int playingnow=0x7f030005; + public static final int playnowlist=0x7f030006; + public static final int remote=0x7f030007; + public static final int setup=0x7f030008; + public static final int splash=0x7f030009; } public static final class string { public static final int app_name=0x7f040001; Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/drawable/border.ico =================================================================== (Binary files differ) Property changes on: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/drawable/border.ico ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/icon.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/icon.xml 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/icon.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -1,23 +1,12 @@ -<LinearLayout -xmlns:android="http://schemas.android.com/apk/res/android" -android:id="@+id/widget44" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:orientation="vertical" -android:layout_x="201px" -android:layout_y="165px" -android:gravity="center_horizontal"> -<ImageView -android:id="@+id/icon_image" -android:layout_width="wrap_content" -android:layout_height="wrap_content"> -</ImageView> -<TextView -android:id="@+id/icon_text" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:text="TextView" -android:gravity="center_horizontal" -android:textColorHighlight="#656565"> -</TextView> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/widget44" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:orientation="vertical" + android:layout_x="201px" android:layout_y="165px" android:gravity="center_horizontal"> + <ImageView android:id="@+id/icon_image" android:layout_width="wrap_content" + android:layout_height="wrap_content"> + </ImageView> + <TextView android:id="@+id/icon_text" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:text="TextView" + android:gravity="center_horizontal" android:textColorHighlight="#656565"> + </TextView> </LinearLayout> \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/list_item.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/list_item.xml (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/list_item.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="wrap_content" android:gravity="left|center" + android:layout_width="wrap_content" android:paddingBottom="5px" + android:paddingTop="5px" android:paddingLeft="5px"> + <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:gravity="center" + android:background="@drawable/border" android:textColor="#000000" + android:text="hi"></TextView> + <TextView android:text="@+id/TextView02" android:id="@+id/TextView02" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginLeft="10px" android:textColor="#000000"></TextView> +</LinearLayout> \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playingnow.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playingnow.xml 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playingnow.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -1,6 +1,8 @@ <LinearLayout android:id="@+id/LinearLayout01" android:orientation="vertical" android:layout_width="fill_parent" - android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> + android:layout_height="fill_parent" + android:background="@drawable/back" + xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/now_playing" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="NOW PLAYING" Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playnowlist.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playnowlist.xml (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/playnowlist.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <TextView android:id="@+id/TextView01" android:layout_height="wrap_content" + android:text="Actual playlist" + android:textStyle="normal|bold" android:gravity="center_vertical|center_horizontal" + android:layout_width="fill_parent"></TextView> + <ListView android:id="@+id/ListView01" android:layout_height="wrap_content" + android:layout_width="fill_parent"> + </ListView> +</LinearLayout> \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/remote.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/remote.xml 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/remote.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -1,72 +1,33 @@ <?xml version="1.0" encoding="utf-8"?> -<AbsoluteLayout -android:id="@+id/widget0" -android:layout_width="fill_parent" -android:layout_height="fill_parent" -android:background="@drawable/back" -xmlns:android="http://schemas.android.com/apk/res/android" -> -<Button -android:id="@+id/btnUp" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:background="@drawable/up_icon" -android:layout_x="130px" -android:layout_y="100px" -> -</Button> -<Button -android:id="@+id/btnReturn" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:text="Return" -android:layout_x="10px" -android:layout_y="8px" -> -</Button> -<Button -android:id="@+id/btnCancel" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:background="@drawable/close_icon" -android:layout_x="260px" -android:layout_y="8px" -> -</Button> -<Button -android:id="@+id/btnOk" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:background="@drawable/accept_icon" -android:layout_x="130px" -android:layout_y="175px" -> -</Button> -<Button -android:id="@+id/btnDown" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:background="@drawable/down_icon" -android:layout_x="130px" -android:layout_y="250px" -> -</Button> -<Button -android:id="@+id/btnRight" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:background="@drawable/next_icon" -android:layout_x="205px" -android:layout_y="175px" -> -</Button> -<Button -android:id="@+id/btnLeft" -android:layout_width="wrap_content" -android:layout_height="wrap_content" -android:background="@drawable/back_icon" -android:layout_x="55px" -android:layout_y="175px" -></Button> +<AbsoluteLayout android:id="@+id/widget0" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:background="@drawable/back" xmlns:android="http://schemas.android.com/apk/res/android"> + <Button android:id="@+id/btnUp" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:background="@drawable/up_icon" + android:layout_x="130px" android:layout_y="100px"> + </Button> + <Button android:id="@+id/btnReturn" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:text="Return" + android:layout_x="10px" android:layout_y="8px"> + </Button> + <Button android:id="@+id/btnCancel" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:background="@drawable/close_icon" + android:layout_x="260px" android:layout_y="8px"> + </Button> + <Button android:id="@+id/btnOk" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:background="@drawable/accept_icon" + android:layout_x="130px" android:layout_y="175px"> + </Button> + <Button android:id="@+id/btnDown" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:background="@drawable/down_icon" + android:layout_x="130px" android:layout_y="250px"> + </Button> + <Button android:id="@+id/btnRight" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:background="@drawable/next_icon" + android:layout_x="205px" android:layout_y="175px"> + </Button> + <Button android:id="@+id/btnLeft" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:background="@drawable/back_icon" + android:layout_x="55px" android:layout_y="175px"></Button> </AbsoluteLayout> \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/res/layout/setup.xml 2010-11-25 19:46:56 UTC (rev 3981) @@ -1,32 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" - android:padding="15dip" - android:background="@drawable/back"> -<TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="MediaPortal IP"></TextView> -<EditText android:id="@+id/server_ip" - android:layout_height="wrap_content" - android:layout_width="fill_parent" - android:text="192.168.0.30" - android:inputType="text"></EditText> -<TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="MediaPortal Port"></TextView> -<EditText android:id="@+id/server_port" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="8200" android:inputType="number|numberSigned"></EditText> -<Button - android:id="@+id/btnReturnSetup" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Return"></Button> - +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:layout_height="fill_parent" + android:orientation="vertical" android:padding="15dip" + android:background="@drawable/back"> + <TextView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:text="MediaPortal IP"></TextView> + <EditText android:id="@+id/server_ip" android:layout_height="wrap_content" + android:layout_width="fill_parent" android:text="192.168.0.30" + android:inputType="text"></EditText> + <TextView android:layout_width="fill_parent" + android:layout_height="wrap_content" android:text="MediaPortal Port"></TextView> + <EditText android:id="@+id/server_port" android:layout_width="fill_parent" + android:layout_height="wrap_content" android:text="8200" + android:inputType="number|numberSigned"></EditText> + <Button android:id="@+id/btnReturnSetup" android:layout_width="wrap_content" + android:layout_height="wrap_content" android:text="Return"></Button> + </LinearLayout> Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -13,7 +13,6 @@ import org.apache.http.util.ByteArrayBuffer; - import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Environment; @@ -88,7 +87,7 @@ // BufferedInputStream bis = new BufferedInputStream(in); ByteArrayBuffer baf = new ByteArrayBuffer(50); - int current = 0; + //int current = 0; byte[] bb = new byte[1024]; int l = in.read(bb, 0, 1024); Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -18,15 +18,18 @@ import android.content.res.AssetManager; import android.os.Bundle; import android.os.Handler; +import android.os.SystemClock; import android.view.View; -import android.widget.Button; import android.widget.ImageButton; +import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; -public class nowplaying extends Activity{ +public class nowplaying extends Activity { public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + + private Handler mHandler = new Handler(); /** Called when the activity is first created. */ @Override @@ -34,15 +37,13 @@ super.onCreate(savedInstanceState); setContentView(R.layout.playingnow); - update(); - ImageButton btn1 = (ImageButton) findViewById(R.id.now_prev); ImageButton btn2 = (ImageButton) findViewById(R.id.now_stop); ImageButton btn3 = (ImageButton) findViewById(R.id.now_pause); ImageButton btn4 = (ImageButton) findViewById(R.id.now_play); ImageButton btn5 = (ImageButton) findViewById(R.id.now_next); ImageButton btn6 = (ImageButton) findViewById(R.id.now_list); - + btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { PostCommand("previous"); @@ -70,14 +71,36 @@ }); btn6.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { - //show list + Intent myIntent = new Intent(view.getContext(), + nowplaylist.class); + startActivityForResult(myIntent, 0); } }); - + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 1000); } + + @Override + public void onStart() { + super.onStart(); + update(); + } - private void update() - { + @Override + public void onPause() { + super.onPause(); + mHandler.removeCallbacks(mUpdateTimeTask); + } + + private Runnable mUpdateTimeTask = new Runnable() { + public void run() { + update(); + mHandler.postDelayed(mUpdateTimeTask, 1000); + } + }; + + private void update() { SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, MODE_PRIVATE); @@ -87,26 +110,34 @@ nowplayinghandler handler = nowplayinghandler.getinstance(); handler.setconnection(HttpServer, HttpPort); handler.fetchdata(); - + TextView txt1 = (TextView) findViewById(R.id.now_artist); - txt1.setText(handler.Artist); + txt1.setText(nowplayinghandler.Artist); TextView txt2 = (TextView) findViewById(R.id.now_title); - txt2.setText(handler.Title); + txt2.setText(nowplayinghandler.Title); TextView txt3 = (TextView) findViewById(R.id.now_album); - txt3.setText(handler.Album); - + txt3.setText(nowplayinghandler.Album); + TextView txt4 = (TextView) findViewById(R.id.now_playing_t_left); - txt4.setText(handler.Actual); + txt4.setText(nowplayinghandler.Actual); TextView txt5 = (TextView) findViewById(R.id.now_playing_right); - txt5.setText(handler.Total); - - //todo progressbar - + txt5.setText(nowplayinghandler.Total); + + String[] p1 = nowplayinghandler.Actual.split(":"); + String[] p2 = nowplayinghandler.Total.split(":"); + if ((p1.length == 2) && (p1.length == 2)) { + int x1 = Integer.parseInt(p1[0]) * 60 + Integer.parseInt(p1[1]); + int x2 = Integer.parseInt(p2[0]) * 60 + Integer.parseInt(p2[1]); + int xy = x1 * 100 / x2; + SeekBar seek = (SeekBar) findViewById(R.id.now_progress); + seek.setProgress(xy); + } } - + public void PostCommand(String button) { - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE , MODE_PRIVATE); + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, + MODE_PRIVATE); String HttpServer = settings.getString("Server", "192.168.0.30"); String HttpPort = settings.getString("Port", "8200"); @@ -149,8 +180,8 @@ Toast.LENGTH_LONG).show(); e.printStackTrace(); } catch (IOException e) { - Toast.makeText(nowplaying.this, "TIME OUT SERVER", Toast.LENGTH_LONG) - .show(); + Toast.makeText(nowplaying.this, "TIME OUT SERVER", + Toast.LENGTH_LONG).show(); e.printStackTrace(); } } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -7,13 +7,6 @@ public class nowplayingXmlHandler extends DefaultHandler { Boolean currentElement = false; String currentValue = null; - - public static String Title; - public static String Artist; - public static String Album; - public static String Total; - public static String Actual; - public static String Track; /** * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) @@ -22,7 +15,7 @@ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { currentElement = true; - + currentValue = "..."; } /** @@ -35,12 +28,12 @@ currentElement = false; /** set value */ - if (localName == "Artist") {Artist =currentValue;} - if (localName == "Title") {Title =currentValue;} - if (localName == "Album") {Album =currentValue;} - if (localName == "Track") {Track =currentValue;} - if (localName == "TotalTime") {Total =currentValue;} - if (localName == "ActualTime") {Actual =currentValue;} + if (localName == "Artist") {nowplayinghandler.Artist =currentValue;} + if (localName == "Title") {nowplayinghandler.Title =currentValue;} + if (localName == "Album") {nowplayinghandler.Album =currentValue;} + if (localName == "Track") {nowplayinghandler.Track =currentValue;} + if (localName == "TotalTime") {nowplayinghandler.Total =currentValue;} + if (localName == "ActualTime") {nowplayinghandler.Actual =currentValue;} } /** Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -2,11 +2,9 @@ import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; -import java.net.URLEncoder; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -16,10 +14,6 @@ import org.xml.sax.SAXException; import org.xml.sax.XMLReader; -import android.graphics.Bitmap; - -import mediaportal.remote.directoryItems; - public class nowplayinghandler { private static nowplayinghandler instance; @@ -29,14 +23,14 @@ private String _server; private String _port; - public String Title; - public String Artist; - public String Album; - public String Track; - public String Total; - public String Actual; - public String PlayerState; - + public static String Title; + public static String Artist; + public static String Album; + public static String Track; + public static String Total; + public static String Actual; + public static String PlayerState; + public static nowplayinghandler getinstance() { if (instance == null) instance = new nowplayinghandler(); @@ -54,7 +48,7 @@ public void fetchdata() { - String fileUrl = "http://" + _server + ":" + _port + "/nowplaying"; + String fileUrl = "http://" + _server + ":" + _port + "/nowplaying/now.xml"; URL myFileUrl = null; try { @@ -103,13 +97,6 @@ } is.close(); sp.reset(); - - Artist = nowplayingXmlHandler.Artist; - Title = nowplayingXmlHandler.Title; - Track = nowplayingXmlHandler.Track; - - Total = nowplayingXmlHandler.Total; - Actual = nowplayingXmlHandler.Actual; } catch (IOException e) { // TODO Auto-generated catch block Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -0,0 +1,197 @@ +package mediaportal.remote; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.content.res.AssetManager; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +public class nowplaylist extends Activity { + + private static final String[] country = { "Iceland", "India", "Indonesia", + "Iran", "Iraq", "Ireland", "Israel", "Italy", "Laos", "Latvia", + "Lebanon", "Lesotho ", "Liberia", "Libya", "Lithuania", + "Luxembourg" }; + private static final String[] curr = { "ISK", "INR", "IDR", "IRR", "IQD", + "EUR", "ILS", "EUR", "LAK", "LVL", "LBP", "LSL ", "LRD", "LYD", + "LTL ", "EUR" }; + + private static class EfficientAdapter extends BaseAdapter { + + private LayoutInflater mInflater; + + public EfficientAdapter(Context context) { + mInflater = LayoutInflater.from(context); + } + + public int getCount() { + nowplaylisthandler handler = nowplaylisthandler.getinstance(); + return handler.PlayList.size(); + //return country.length; + } + + public Object getItem(int position) { + return position; + } + + public long getItemId(int position) { + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + if (convertView == null) { + convertView = mInflater.inflate(R.layout.list_item, null); + holder = new ViewHolder(); + holder.text = (TextView) convertView + .findViewById(R.id.TextView01); + holder.text2 = (TextView) convertView + .findViewById(R.id.TextView02); + + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + nowplaylisthandler.PlayListItem item = nowplaylisthandler.PlayList.get(position); + + holder.text.setText(String.valueOf(position +1)); + holder.text2.setText(item.Title); + //holder.text.setText(curr[position]); + //holder.text2.setText(country[position]); + + convertView.setBackgroundColor((position & 1) == 1 ? Color.WHITE + : Color.LTGRAY); + + return convertView; + } + + static class ViewHolder { + TextView text; + TextView text2; + } + } + + public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.playnowlist); + + update(); + + ListView l1 = (ListView) findViewById(R.id.ListView01); + l1.setAdapter(new EfficientAdapter(this)); + l1.setOnItemClickListener(new AdapterView.OnItemClickListener() + { + //@override + public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, + long arg3) { + //Toast.makeText(getBaseContext(), "You clciked "+country[arg2], Toast.LENGTH_LONG).show(); + } + } + ); + + ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); + l1.setDivider(divcolor); + l1.setDividerHeight(2); + /* + * update(); + * + * int x = nowplaylisthandler.PlayList.size(); Log.d("Android remote", + * "read " + x); + * + * // setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, + * // COUNTRIES)); + */ + } + + private void update() { + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, + MODE_PRIVATE); + + String HttpServer = settings.getString("Server", "192.168.0.30"); + String HttpPort = settings.getString("Port", "8200"); + + nowplaylisthandler handler = nowplaylisthandler.getinstance(); + handler.setconnection(HttpServer, HttpPort); + handler.fetchdata(); + } + + public void PostCommand(String button) { + + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, + MODE_PRIVATE); + + String HttpServer = settings.getString("Server", "192.168.0.30"); + String HttpPort = settings.getString("Port", "8200"); + + HttpParams httpParameters = new BasicHttpParams(); + HttpConnectionParams.setConnectionTimeout(httpParameters, 3000); + HttpConnectionParams.setSoTimeout(httpParameters, 3000); + + HttpClient httpclient = new DefaultHttpClient(httpParameters); + HttpPost httppost = new HttpPost("http://" + HttpServer + ":" + + HttpPort); + + try { + + AssetManager assetManager = getAssets(); + + InputStream inputStream = null; + inputStream = assetManager.open("cmd_" + button + ".xml"); + + int x = inputStream.read(); + + String xml = ""; + + while (x != -1) { + xml = xml + (char) x; + x = inputStream.read(); + } + + StringEntity se = new StringEntity(xml, "UTF-8"); + se.setContentType("application/atom+xml"); + + httppost.setEntity(se); + + // HttpResponse response; + // response = httpclient.execute(httppost); + httpclient.execute(httppost); + + } catch (ClientProtocolException e) { + Toast.makeText(nowplaylist.this, "ERROR CONNECTION SERVER", + Toast.LENGTH_LONG).show(); + e.printStackTrace(); + } catch (IOException e) { + Toast.makeText(nowplaylist.this, "TIME OUT SERVER", + Toast.LENGTH_LONG).show(); + e.printStackTrace(); + } + } + +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylistXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylistXmlHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylistXmlHandler.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -0,0 +1,69 @@ +package mediaportal.remote; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +public class nowplaylistXmlHandler extends DefaultHandler { + Boolean currentElement = false; + String currentValue = null; + nowplaylisthandler.PlayListItem item = null; + + /** + * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) + */ + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { + currentElement = true; + currentValue = "..."; + + if (localName == "Item") + item = new nowplaylisthandler.PlayListItem(); + } + + /** + * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> + * ) + */ + @Override + public void endElement(String uri, String localName, String qName) + throws SAXException { + + currentElement = false; + + /** set value */ + if (localName == "Title") { + item.Title = currentValue; + } + if (localName == "Duration") { + item.Duration = currentValue; + } + if (localName == "Played") { + item.Played = currentValue; + } + if (localName == "Typ") { + item.Typ = currentValue; + } + if (localName == "Item") { + nowplaylisthandler.PlayList.add(item); + item = null; + } + + } + + /** + * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to + * get AndroidPeople Character ) + */ + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + if (currentElement) { + currentValue = new String(ch, start, length); + currentElement = false; + } + + } + +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -0,0 +1,111 @@ +package mediaportal.remote; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +public class nowplaylisthandler { + + private static nowplaylisthandler instance; + + public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + + private String _server; + private String _port; + +public static ArrayList<PlayListItem> PlayList = new ArrayList<PlayListItem>(); + + public static class PlayListItem + { + public String Title; + public String Duration; + public String Played; + public String Typ; + } + + public static nowplaylisthandler getinstance() { + if (instance == null) + instance = new nowplaylisthandler(); + return instance; + } + + private nowplaylisthandler() { + + } + + public void setconnection(String server, String port) { + _server = server; + _port = port; + } + + public void fetchdata() { + + PlayList = new ArrayList<PlayListItem>(); + String fileUrl = "http://" + _server + ":" + _port + "/nowplaying/list.xml"; + + URL myFileUrl = null; + try { + myFileUrl = new URL(fileUrl); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + HttpURLConnection conn = (HttpURLConnection) myFileUrl + .openConnection(); + conn.setReadTimeout(10000); + conn.setDoInput(true); + conn.connect(); + // int length = conn.getContentLength(); + InputStream is = conn.getInputStream(); + + SAXParserFactory spf = SAXParserFactory.newInstance(); + SAXParser sp = null; + try { + sp = spf.newSAXParser(); + } catch (ParserConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + XMLReader reader = null; + try { + reader = sp.getXMLReader(); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + nowplaylistXmlHandler handler = new nowplaylistXmlHandler(); + + reader.setContentHandler(handler); + try { + reader.parse(new InputSource(is)); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + is.close(); + sp.reset(); + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -34,9 +34,6 @@ String HttpServer = settings.getString("Server", "192.168.0.30"); String HttpPort = settings.getString("Port", "8200"); - // ImageAdapter.downloadFile("http://" + HttpServer + ":" + HttpPort - // + "/pictures/2010/2008%2001%2023"); - picturehandler h = picturehandler.getinstance(); h.setconnection(HttpServer, HttpPort); h.getrootdirectory(); @@ -48,7 +45,7 @@ public void onItemClick(AdapterView<?> parent, View v, int position, long id) { - TextView tv = (TextView) v.findViewById(R.id.icon_text); + //TextView tv = (TextView) v.findViewById(R.id.icon_text); ImageView iv = (ImageView) v.findViewById(R.id.icon_image); picItem pic = (picItem) iv.getTag(); Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java 2010-11-25 19:46:56 UTC (rev 3981) @@ -79,7 +79,6 @@ txt.setText(pic.selectedPictureName); } } catch (Exception e) { - String g = e.getStackTrace().toString(); // nothing } return false; Modified: trunk/plugins/AndroidRemote/Release/Android Server communication.docx =================================================================== (Binary files differ) Modified: trunk/plugins/AndroidRemote/Release/nowplaying.jpg =================================================================== (Binary files differ) Added: trunk/plugins/AndroidRemote/Release/nowplayingList.jpg =================================================================== (Binary files differ) Property changes on: trunk/plugins/AndroidRemote/Release/nowplayingList.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj 2010-11-25 19:46:56 UTC (rev 3981) @@ -66,6 +66,9 @@ <DependentUpon>Setup.cs</DependentUpon> </EmbeddedResource> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="favicon.ico" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs 2010-11-25 19:46:56 UTC (rev 3981) @@ -70,7 +70,7 @@ string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) { - Server= xmlreader.GetValueAsString("android", "server", "192.168.0.30"); + Server = xmlreader.GetValueAsString("android", "server", "192.168.0.30"); Port = xmlreader.GetValueAsString("android", "port", "8200"); PicturePath = xmlreader.GetValueAsString("android", "pictures", Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-11-25 08:32:51 UTC (rev 3980) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-11-25 19:46:56 UTC (rev 3981) @@ -45,6 +45,8 @@ private byte[] read; private byte[] buffer; + private static Bitmap actualCover = null; + public Request(Socket Socket) { socket = Socket; @@ -62,6 +64,8 @@ if (clientmessage.Contains("Continue")) { + AndroidServer.logDebug("receive HTTP Continue"); + allMessage = allMessage + clientmessage.Substring(0, bytes); sendMessage(socket, "HTTP/1.0 100 Continue\r\n"); sendMessage(socket, "\r\n"); @@ -72,6 +76,8 @@ if (clientmessage.Contains("POST")) { + AndroidServer.logDebug("receive HTTP POST"); + sendMessage(socket, "HTTP/1.0 200 OK\r\n"); sendMessage(socket, "\r\n"); @@ -86,7 +92,7 @@ req = HttpUtility.UrlDecode(req); - System.Diagnostics.Debug.WriteLine("GET Request : " + req); + AndroidServer.logDebug("receive HTTP GET : " + req); #region pictures if (req.StartsWith("/pictures")) @@ -160,13 +166,16 @@ { ReplyNowPlayingPlaylist(); } + else if (req.StartsWith("/nowplaying/cover")) + { + ReplyNowCover(); + } #endregion #region favicon else if (req.StartsWith("/favicon.ico")) { - //todo use resource - ReplyPictureFile("c:\\favicon.ico"); + ReplyFavIcon(); } #endregion @@ -190,6 +199,7 @@ private void ExceuteCommand(string Message) { + AndroidServer.logDebug("execute command"); if (Message.Contains("ACTION_PLAY")) { Action action = new Action(Action.ActionType.ACTION_PLAY, 0, 0); @@ -276,6 +286,7 @@ msg += "</Directory>\r\n"; // send sendMessage(socket, msg); + AndroidServer.logDebug("Reply picture dir"); } else { @@ -314,6 +325,7 @@ sendMessage(socket, msg); // content sendBytes(socket, b); + AndroidServer.logDebug("Reply picture file"); } else { @@ -349,6 +361,7 @@ sendMessage(socket, msg); // content sendBytes(socket, b); + AndroidServer.logDebug("Reply picture thumb file"); } else { @@ -389,6 +402,7 @@ msg += "</Directory>\r\n"; // send sendMessage(socket, msg); + AndroidServer.logDebug("Reply music dir"); } else { @@ -411,6 +425,7 @@ sendMessage(socket, msg); // content sendBytes(socket, b); + AndroidServer.logDebug("Reply music file"); } else { @@ -425,6 +440,18 @@ string album = GUIPropertyManager.GetProperty("#Play.Current.Album"); string track = GUIPropertyManager.GetProperty("#Play.Current.Track"); + string cover = GUIPropertyManager.GetProperty("#Play.Current.Thumb"); + if (File.Exists(cover)) + { + try + { + actualCover = (Bitmap)Bitmap.FromFile(cover); + } + catch { }; + } + else + actualCover = null; + string actual = GUIPropertyManager.GetProperty("#currentplaytime"); string total = GUIPropertyManager.GetProperty("#duration"); @@ -447,7 +474,6 @@ album = HttpUtility.HtmlEncode(album); title = HttpUtility.HtmlEncode(title); - string msg = string.Empty; // header msg += "HTTP/1.0 200 Ok\r\n"; @@ -464,7 +490,10 @@ msg += "<Artist>" + artist + "</Artist>\r\n"; msg += "<Album>" + album + "</Album>\r\n"; msg += "<Track>" + track + "</Track>\r\n"; - msg += "<Cover></Cover>\r\n"; + if (actualCover != null) + msg += "<Cover>True</Cover>\r\n"; + else + msg += "<Cover>False</Cover>\r\n"; msg += "<ActualTime>" + actual + "</ActualTime>\r\n"; msg += "<TotalTime>" + total + "</TotalTime>\r\n"; @@ -472,6 +501,7 @@ msg += "</NowPlaying>\r\n"; // send sendMessage(socket, msg); + AndroidServer.logDebug("Reply now playing"); } private void ReplyNowPlayingPlaylist() { @@ -512,16 +542,58 @@ msg += "</Item>\r\n"; } + msg += "</NowPlayingPlaylist>\r\n"; - msg += "</NowPlayingPlaylist>\r\n"; // send - sendMessage(socket, msg); + AndroidServer.logDebug("Reply now playing list"); } + private void ReplyNowCover() + { + if (actualCover != null) + { + byte[] b; + if ((actualCover.Width > 250) || (actualCover.Height > 250)) + { + Bitmap thumb = (Bitmap)actualCover.Clone(); + thumb = MediaPortal.Util.BitmapResize.Resize(ref thumb, 250, 250, false, true); + + b = BildToByteArray((Image)thumb); + } + else + { + b = BildToByteArray((Image)actualCover); + } + + if (b != null) + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: image/jpeg" + "\r\n"; + msg += "Content-Length: " + b.Length + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + sendMessage(socket, msg); + // content + sendBytes(socket, b); + AndroidServer.logDebug("Reply play now cover file"); + } + else + { + SendServerError("play now cover", "ReplyNowThumb"); + } + } + else + { + SendErrorFile("thumb.jpg"); + } + } + private void SendErrorURL(string Url) { - System.Diagnostics.Debug.WriteLine("URL NOT FOUND " + Url); + AndroidServer.logDebug("URL NOT FOUND " + Url); string msg = string.Empty; // header msg += "HTTP/1.0 404 Not Found\r\n"; @@ -543,7 +615,7 @@ } private void SendErrorFile(string FileName) { - System.Diagnostics.Debug.WriteLine("FILE NOT FOUND " + FileName); + AndroidServer.logDebug("FILE NOT FOUND " + FileName); string msg = string.Empty; // header msg += "HTTP/1.0 404 Not Found\r\n"; @@ -565,7 +637,7 @@ } private void SendServerError(string Data, string Who) { - System.Diagnostics.Debug.WriteLine("Internal Server Error " + Who); + AndroidServer.logDebug("Internal Server Error " + Who + " / " + Data); string msg = string.Empty; // header msg += "HTTP/1.0 500 Internal Server Error\r\n"; @@ -586,6 +658,31 @@ sendMessage(socket, msg); } + private void ReplyFavIcon() + { + Stream stream = GetEmbeddedResourceStream("AndroidRemote.favicon.ico"); + byte[] b = StreamToByteArray(stream); + + if (b != null) + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: image/jpeg" + "\r\n"; + msg += "Content-Length: " + b.Length + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + sendMessage(socket, msg); + // content + sendBytes(socket, b); + AndroidServer.logDebug("Reply favicon"); + } + else + { + SendServerError("favicon.ico", "ReplyFavIcon"); + } + } + private int readmessage(byte[] ByteArray, ref Socket s, ref String clientmessage) { int bytes = s.Receive(ByteArray, 1024, 0); @@ -654,6 +751,36 @@ IS.Flush(); return IS.ToArray(); } + private byte[] StreamToByteArray(Stream stream) + { + byte[] _Buffer = null; + try + { + // attach stream to binary reader + System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(stream); + + // get total byte length of the file + long _TotalBytes = stream.Length; + + // read entire file into buffer + _Buffer = _BinaryReader.ReadBytes((Int32)_TotalBytes); + + // close file reader + _BinaryReader.Close(); + } + catch (Exception _Exception) + { + // Error + Console.WriteLine("Exception caught in process: {0}", _Exception.ToString()); + } + + return _Buffer; + } + + protected Stream GetEmbeddedResourceStream(string ResourceName) + { + return System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName); + } } } Added: trunk/plugins/AndroidRemote/Server/AndroidRemote/favicon.ico =================================================================== (Binary files differ) Property changes on: trunk/plugins/AndroidRemote/Server/AndroidRemote/favicon.ico ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |