Amazon Gift Cards

Sunday, March 21, 2010

Google TV and why its important

Last week Google, Intel, Sony and Logitech announced Google TV, while everyone seems to think that its just a stab at something like boxee box, the partnership has more than what meets the eye.

Google - for Google they want to put their android in much device as possible, they said this when they released the MIPS port of Andriod, now before MIPS gets big with android, Intel need to enter the picture, they need to enter now or else it would be like ARM in mobiles where is almost a monopoly, MIPS is already huge but we will be seeing a transformation on your home appliances making them smarter then before. Now this move is huge for Andriod for right now it doesn't have an official x86 or x64 chipset for the OS. Android as what most people expect would be the wheel to Google's ads platform, if you have people searching then you have ads to show.

Intel - they said they want to enter the mobile scene, they made Moblin out of these desire and later on added Nokia on their track that made the world's most selling phone company to dump ARM on some of its phone like N900 then later on combine Meamo and Moblin to make MeeGo. Now it seems they can't force Google to build one for mobile device and they need to get that OS running on their chips because like Google's Ads, Intel cares so much on putting their chips on every possible device. And technically Andriod having an Intel chipset for Google TV could be easily be ported to mobiles.

Sony - the supposed original maker of Nexus One is once again approach by Google, its not their first time they collaborate, remember Google chrome to be the default browser in every vaio, Sony is huge worldwide and it has some interesting products but recently they can't strike a good selling product and they seems to have the need to have one and they do know that Andriod and Internet based tv-setup boxes are becoming huge in US, therefore if this product succeeded would be their way of surviving

Logitech - they are so well known for their computer products like keyboard and mouse. Having them here would mean that they would create remote controls for Google TV, but that's not the fun part, the fun part is that Logitech's device would have drivers for Android and if Logitech is kind enough it would mean official drivers for Linux on their products.

Another good thing that would come out of this partnership is that Andriod is getting out of Mobile device screen size and getting into a screen that varies so much in inches and if they did a good job here then expect android to live in your PC anytime and with Intel and their 90%+ x86 or x64 share on desktop, Android would be huge.

The bad impact is that it will further fragment the Android market share and harder for developers to develop programs.

Sunday, March 14, 2010

Play MediaPlayer with Authentication on Android

I was back to the Android lang with the free Nexus One from Google, and had a project in mind that involves MediaPlayer and for which here is how i did it.

private void playAudio(String mediaUrl) {
  try {
    URLConnection cn = new URL(mediaUrl).openConnection();
    cn.setRequestProperty("Your Header Name", "Your Header Value");
    InputStream is = cn.getInputStream();
    // create file to store audio
    File mediaFile = new File(this.getCacheDir(),"mediafile");
    FileOutputStream fos = new FileOutputStream(mediaFile);   
    byte buf[] = new byte[16 * 1024];
    // write to file until complete
    do {
      int numread =;   
      if (numread <= 0)  
      fos.write(buf, 0, numread);
    } while (true);
    MediaPlayer mp = new MediaPlayer();
    // create listener to tidy up after playback complete
    MediaPlayer.OnCompletionListener listener = new MediaPlayer.OnCompletionListener(){
      public void onCompletion(MediaPlayer mp) {
        // free up media player
        Log.i("MediaPlayer.OnCompletionListener", "MediaPlayer Released");

    FileInputStream fis = new FileInputStream(mediaFile);
  } catch (Exception e) {

First up this code came from where it was the answer to a different question.

URLConnection cn = new URL(mediaUrl).openConnection();
cn.setRequestProperty("Your Header Name", "Your Header Value");

This is the core part and probably the only explanation beside the concept of the code that ill do. On here you create a URLConnection on where you can specify the request(headers) Property, depending on how you made the authentication on your server (say like GData) you can pass any headers related values.

Now on the concept, what the code does is like what it had said in stackoverflow, it downloads the music, outputs it to a FileOutputStream under the mediaFile File, where then we get to stream it to the FileInputStream which then we use as our data source on our MediaPlayer.

Hope this helps :)