Dear Friends,
I was reading a lot about Orb and how great it is to stream Media direct from my PC to my Mobile.
Anyway I did not found an APP for my Android G1 and as I was reading there is no APP from ORB to expect till June.
As I am a Coder I was unable to wait. Especialy I am a Newbie in learning Android (usually PHP COder), that was a little challenge for me to do.
Finaly I got a small Version to work that I like to share with you. Its not at all a real Orb Client as you may expect, but it works for me to scan for all my Video Media that I shared in my Orb, let it display in a Listview and when I click on one of the Titles it starts playing
Btw. I was only able to test it with a WIFI Network.
There are several improvments to do. Like:
- a selection for Audio, Photos, Documents, Playlists …
- a Thread that the loading happens in the Background
- a Setup Feature to store and change Userid, Password and APiKey.
But as I make it opensource you can help to improve it.
The most work for me was to understand and test out the API Function from ORB.
Also when there is a API Description from ORB http://developer.orb.com
it was not always really understandable how to do.
You may like to change the Code as you like. Remember when you publish it into the Market
you need a Commercial APi Key from ORb. Yes, I know on Orb is written you need a Commercial Key when
you like to make Money from it or it is business in any other way. Finaly I thought to make it freeware
but after I nice Talk with Luc Julia from Orb he told me: “Remember that you can’t distribute an application using a developer key, it will be invalidated. You need to get a commercial key for that purpose.”
I asked 3 Times but at all it looks for any Case you publish it you need commercial key.
Ok, here is my Prework and I hope you can use it for your Purposes.
Btw: I called it “OrbAnd”
You can download the full OrbAnd Source here (prepared for SDK1.1 and Eclipse)
Yours
Chris
–Orband.Java
/* * OrbAnd 0.1 Alpha * * Copyright (C) 2009 Christian Albert Müller * http://www.christian-albert-mueller.com * * This Source Code is Freeware, OpenSource as you like to call it. * I do not take any responsibility for its usage and also I dont have * Time to explain the Source. * * If you like to Develop this Version you are welcome to send me your * Updates and I will check them and keep the right to publish it for * other Users on my Page. * * If you can make some Explanations for other Users may be helpful. * * Should you distribute this Version you need a Commercial Key from Orb * * I am not related with ORB and its not an official Work from ORB * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * You can extend this Copyright with your Changes and keep Responsible * for your Work. * * * To start: * - go to: https://mycast.orb.com/orb/html/createAPIKey.html * - Enter your ORB Login and request an Developer API Key * - Enter your Login, Password and API Key into the Source Code Bellow * - Compile the Source ... and Enjoy Orb on your Android Mobile* * Infos about Error Codes and XML Requests at: http://developer.orb.com * */ package com.development.orband; import java.io.BufferedInputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.HashMap; import org.apache.http.util.ByteArrayBuffer; import org.apache.http.util.EncodingUtils; import android.app.ListActivity; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class Orband extends ListActivity { /** Called when the activity is first created. */ private static final String TAG = "Orband"; String Username = "yourUsername"; String Password = "yourPassword"; String apikey = "yourApiKey"; String html; String dummystr; String sid; //Initializing the ListView private ArrayAdapter<String> mAdapter; private ArrayList<String> mStrings = new ArrayList<String>(); //Just a small Status Line in the Top TextView toptext; static int countlistentries; static Bitmap[] inipics; //ArrayList for Orb Responses (MediaTitle, Url ...) ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); HashMap<String,String> item = new HashMap<String,String>(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); toptext = (TextView) findViewById(R.id.toptext); mAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, mStrings); setListAdapter(mAdapter); ListView MyOrbList = getListView(); MyOrbList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { String Mid = list.get(position).get("id"); //Get STREAM Information html = loaddata("http://api.orb.com/orb/xml/stream?sid="+sid+"&mediumId="+Mid+"&streamFormat=3gp&type=pda&width=480&height=360"); int status = Integer.parseInt(GetXmlInnerNr("status", "code", html, 1)); String uril = GetXmlInnerNr("item","url",html,1); Toast.makeText(Orband.this, "Status: "+status+" URL: "+uril,Toast.LENGTH_SHORT).show(); if (status == 0) { Intent i = new Intent(Intent.ACTION_VIEW); Uri u = Uri.parse(uril); i.setData(u); startActivity(i); } } }); do_main(); } private void do_main() { Log.i(TAG, " *------ Login Orb -----*: "); html = loaddata("http://api.orb.com/orb/xml/session.login?apiKey="+apikey+"&l="+Username+"&password="+Password+""); int status = Integer.parseInt(GetXmlInnerNr("status", "code", html, 1)); sid = GetXmlNr("orbSessionId", html, 1); toptext.setText("sid:" + sid + " status:" + status); if (status == 0) { Log.i(TAG, " *------ Load Media Data-----*: "); html = loaddata("http://api.orb.com/orb/xml/media.search?sid="+ sid + "&q=mediaType%3Dvideo&groupBy=author"); // for AUDIO just change the Line above with this // html = loaddata("http://api.orb.com/orb/xml/media.search?sid="+ sid + "&q=mediaType%3Daudio&groupBy=author"); status = Integer.parseInt(GetXmlInnerNr("status", "code", html, 1)); Log.i(TAG, " *------ Media Result Status: " + status); if (status != 0) { toptext.setText("Status Error (2) : " + status); } else { int results = Integer.parseInt(GetXmlInnerNr("searchResult","itemCount", html, 1)); //String ausgabe = "" + results + " Ergebnisse\n"; Log.i(TAG, " *------ Media Result add 1: "); for (int i = 0; i < results; i++) { dummystr=GetXmlNr("field name=\"title\"", html, i); mAdapter.add(dummystr); item = new HashMap<String,String>(); item.clear(); item.put("title",dummystr); item.put("id",GetXmlInnerNr("item","orbMediumId", html, i)); list.add(item); } Log.i(TAG, " *------ Media Result add 2: "); } } else { toptext.setText("Status Error (1) : " + status); } } private String loaddata(String Urli) { try { String mediaUrl = Urli; URLConnection conn; conn = new URL(mediaUrl).openConnection(); InputStream is = conn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); // loading part int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } // Log.i(TAG, " *------ Load Data done -----*: "); html = EncodingUtils.getString(baf.toByteArray(), "UTF-8"); // ------ } catch (Exception e) { Toast.makeText(this, "Shit, Loading Error!", Toast.LENGTH_SHORT).show(); } return html; } public String GetXmlNr(String xtag, String xhtml, int pos) { // Log.i(TAG, " *xhtml: " + xhtml); String x1tag = ""; String x2tag = ""; String retstr = ""; int xstart = 0; int dummy = 0; int xend = 0; int xcont = 0; int xcounter = 0; x1tag = "<" + xtag; dummy = xtag.indexOf(" "); if (dummy != -1) xtag = xtag.substring(0, dummy); x2tag = "</" + xtag + ">"; do { xcounter++; xhtml = xhtml.substring(xcont); xstart = xhtml.indexOf(x1tag); // Log.i(TAG, " *xstart1: " + xstart); xstart = xhtml.indexOf(">", xstart); if (xstart < 0) return ""; xend = xhtml.indexOf(x2tag, xstart); if (xend < 0) return ""; retstr = xhtml.substring(xstart + 1, xend); xcont = xend + x2tag.length(); } while (xcounter < pos); return retstr; } public String GetXmlInnerNr(String xtag, String Attrib, String xhtml, int pos) { String x1tag; int x1len; String x2tag; String retstr; int xstart; int xend; int xcont = 0; int xcounter = 0; do { xcounter++; xhtml = xhtml.substring(xcont); // Log.i(TAG, "* xhtml: " + xhtml); x1tag = "<" + xtag; x1len = x1tag.length(); x2tag = ">"; xstart = xhtml.indexOf(x1tag); if (xstart < 0) return ""; xend = xhtml.indexOf(x2tag, xstart); if (xend < 0) return ""; // Log.i(TAG, "* xstart: " + xstart + " xend: " + xend); String Innerhtml = xhtml.substring(xstart + x1len, xend); // now search in the innerarea x1tag = Attrib + "=\""; x2tag = "\""; x1len = x1tag.length(); xstart = Innerhtml.indexOf(x1tag); if (xstart < 0) return ""; xcont = xend + 1; xend = Innerhtml.indexOf(x2tag, xstart + x1len); if (xend < 0) return ""; retstr = Innerhtml.substring(xstart + x1len, xend); ; } while (xcounter < pos); return retstr; } }
— and here the Main.XML
<?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/toptext" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:transcriptMode="normal"/> </LinearLayout> <div>
—AndroidManifext.XML
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.development.orband" android:versionCode="1" android:versionName="1.0.0"> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Orband" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

Loading ...