From: <kro...@us...> - 2010-12-16 13:22:09
|
Revision: 4036 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4036&view=rev Author: kroko_koenig Date: 2010-12-16 13:22:02 +0000 (Thu, 16 Dec 2010) Log Message: ----------- changed email adress to service.mediaportal + save to sd for mp3 from db Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/readme trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Server/AndroidRemote.suo Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/readme =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/readme 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/readme 2010-12-16 13:22:02 UTC (rev 4036) @@ -16,6 +16,7 @@ view playlist delete item from playlist clear playlist +save files from db to phone Video section ------------- @@ -38,7 +39,8 @@ ------------ Vibration feedback (not completed) switch WIFI on (just msg now) -gesture control for pictures (swipe) / alertdialog +gesture control for pictures (swipe) / alert dialog save files from Android to MP if the MP has no focus the remote doesnt work (normal) -Progress is not displayed +save huge files can cause out of memory, better save stream + Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-12-16 13:22:02 UTC (rev 4036) @@ -43,6 +43,7 @@ public String Rating= ""; public String Filename= ""; public String Duration= ""; + public String ID= ""; } private DbItems currentDbItem; @@ -77,6 +78,7 @@ if (localName == "Rating") {currentDbItem.Rating =currentValue;} if (localName == "Filename") {currentDbItem.Filename =currentValue;} if (localName == "Duration") {currentDbItem.Duration =currentValue;} + if (localName == "ID") {currentDbItem.ID =currentValue;} if (localName == "Item")DbList.add(currentDbItem); } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-16 13:22:02 UTC (rev 4036) @@ -76,13 +76,13 @@ return bitmap; } - public void DownloadFile() { - extStorageDirectory = Environment.getExternalStorageDirectory() - .toString(); - + public void DownloadFile(String Filename, String ID) { + + extStorageDirectory = Environment.getExternalStorageDirectory().toString(); + try { InputStream in = openHttpConnection("http://"+ Settings.Server + ":" + Settings.Port + - "/music/Clementi_Sonatina_Op.36_No.1_Movement_1.mp3"); + "/db_music/getfile?id=" + ID); // BufferedInputStream bis = new BufferedInputStream(in); ByteArrayBuffer baf = new ByteArrayBuffer(50); @@ -97,7 +97,7 @@ } OutputStream outStream = null; - File file = new File(extStorageDirectory, "test.mp3"); + File file = new File(extStorageDirectory, Filename); outStream = new FileOutputStream(file); outStream.write(baf.toByteArray()); Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-16 13:22:02 UTC (rev 4036) @@ -75,6 +75,7 @@ } Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler(this)); + chkStatus(); mHandler.removeCallbacks(mUpdateTimeTask); @@ -117,7 +118,7 @@ int x = 0; int y = 1; - int z = y / x; + int z = y / x; // we do a exception ;-) } }); @@ -176,6 +177,7 @@ private boolean reportExist() { try { + @SuppressWarnings("unused") BufferedReader reader = new BufferedReader(new InputStreamReader( this.openFileInput("stack.trace"))); return true; @@ -199,11 +201,11 @@ Intent sendIntent = new Intent(Intent.ACTION_SEND); String subject = "Error report"; - String body = "Mail this to mar...@go...: " + String body = "Mail this to ser...@go... : " + "\n\n" + trace + "\n\n"; sendIntent.putExtra(Intent.EXTRA_EMAIL, - new String[] { "mar...@go..." }); + new String[] { "ser...@go..." }); sendIntent.putExtra(Intent.EXTRA_TEXT, body); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.setType("message/rfc822"); Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java 2010-12-16 13:22:02 UTC (rev 4036) @@ -31,6 +31,7 @@ import android.graphics.drawable.ColorDrawable; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.util.Log; import android.view.LayoutInflater; @@ -96,7 +97,7 @@ Toast.makeText(musicResults.this, "Playlist has been cleared", Toast.LENGTH_SHORT).show(); break; case 2: - SavetoSDCard(); + SavetoSDCard(selectedItem); Toast.makeText(musicResults.this, selectedItem.Title + " has been transferd", Toast.LENGTH_SHORT).show(); break; @@ -139,8 +140,16 @@ post.Post(xml); } - private void SavetoSDCard() { - + private void SavetoSDCard(ReceiveDbXmlHandler.DbItems Item) { + + String filename = Item.Artist + " - " + Item.Title + ".mp3"; + String id = Item.ID; + + httpHandler h = new httpHandler(); + h.DownloadFile(filename,id); + + String sd = Environment.getExternalStorageDirectory().toString(); + MediaScannerNotifier not = new MediaScannerNotifier(this, sd + "/" + filename, "audio/mpeg"); } private Runnable mUpdateTimeTask = new Runnable() { Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java 2010-12-16 13:22:02 UTC (rev 4036) @@ -31,6 +31,7 @@ import android.graphics.drawable.ColorDrawable; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.util.Log; import android.view.LayoutInflater; @@ -85,7 +86,7 @@ Toast.makeText(musicSong.this, "Playlist has been cleared", Toast.LENGTH_SHORT).show(); break; case 2: - SavetoSDCard(); + SavetoSDCard(selectedItem); Toast.makeText(musicSong.this, selectedItem.Title + " has been transferd", Toast.LENGTH_SHORT).show(); break; @@ -173,8 +174,16 @@ post.Post(xml); } - private void SavetoSDCard() { + private void SavetoSDCard(ReceiveDbXmlHandler.DbItems Item) { + String filename = Item.Artist + " - " + Item.Title + ".mp3"; + String id = Item.ID; + + httpHandler h = new httpHandler(); + h.DownloadFile(filename,id); + + String sd = Environment.getExternalStorageDirectory().toString(); + MediaScannerNotifier not = new MediaScannerNotifier(this, sd + "/" + filename, "audio/mpeg"); } private static class EfficientAdapter extends BaseAdapter { Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-12-16 10:58:24 UTC (rev 4035) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-12-16 13:22:02 UTC (rev 4036) @@ -47,29 +47,27 @@ private Handler mHandler = new Handler(); public static String actualDir = ""; - + public static ArrayList<ReceiveDirectoryXmlHandler.DirItems> pictureList; public static int selectedPicture; - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pictures); - + mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); GridView gridview = (GridView) findViewById(R.id.GridView01); - + gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { - // TextView tv = (TextView) v.findViewById(R.id.icon_text); - // ImageView ImageView iv = (ImageView) v.findViewById(R.id.icon_image); picItem pic = (picItem) iv.getTag(); - + if (pic.typ == "item") { selectedPicture = position - 1; Intent myIntent = new Intent(pictures.this, @@ -103,60 +101,48 @@ }); } - @Override - public void onStart() { - super.onStart(); - - //mHandler.removeCallbacks(mUpdateTimeTask); - //mHandler.postDelayed(mUpdateTimeTask, 100); - } - private Runnable mUpdateTimeTask = new Runnable() { public void run() { - new update().execute(); - //update(); + new update().execute(); } }; - - - private class update extends AsyncTask<String, Void, Void> { - private final ProgressDialog dialog = new ProgressDialog(pictures.this); - - // can use UI thread here - protected void onPreExecute() { - this.dialog.setMessage("Loading..."); - this.dialog.show(); - } - - // automatically done on worker thread (separate from UI thread) - protected Void doInBackground(final String... args) { + private class update extends AsyncTask<String, Void, Void> { + private final ProgressDialog dialog = new ProgressDialog(pictures.this); + + // can use UI thread here + protected void onPreExecute() { + this.dialog.setMessage("Loading..."); + this.dialog.show(); + } + + // automatically done on worker thread (separate from UI thread) + protected Void doInBackground(final String... args) { Log.d("update pictures", "do update folder : " + actualDir); - + ReceiveDirHandler h = ReceiveDirHandler.getinstance(); pictureList = h.getPictureDir(actualDir); - return null; - } - - // can use UI thread here - protected void onPostExecute(final Void unused) { - if (this.dialog.isShowing()) { - this.dialog.dismiss(); - } + return null; + } - if (pictureList.size() == 0) { - Toast.makeText(pictures.this, "TIME OUT SERVER", Toast.LENGTH_SHORT) - .show(); + // can use UI thread here + protected void onPostExecute(final Void unused) { + if (this.dialog.isShowing()) { + this.dialog.dismiss(); + } + + if (pictureList.size() == 0) { + Toast.makeText(pictures.this, "TIME OUT SERVER", + Toast.LENGTH_SHORT).show(); } else { GridView gridview = (GridView) findViewById(R.id.GridView01); gridview.setAdapter(new ImageAdapter2(pictures.this)); } - } - } - - - public class ImageAdapter2 extends BaseAdapter { + } + } + + public class ImageAdapter2 extends BaseAdapter { private Context mContext; public static final int ACTIVITY_CREATE = 10; @@ -188,12 +174,10 @@ LayoutInflater li = LayoutInflater.from(mContext); v = li.inflate(R.layout.icon, null); - } - else - { + } else { v = convertView; } - + if (position > 0) { position = position - 1; @@ -220,7 +204,8 @@ String file = "http://" + Settings.Server + ":" + Settings.Port + "/pictures/"; file += actualDir + item.File + ".thb"; - item.Picture = http.DownloadImage(file.replaceAll(" ", "%20")); + item.Picture = http.DownloadImage(file.replaceAll(" ", + "%20")); iv.setImageBitmap(item.Picture); if (item.Picture == null) 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. |