Thursday, 13 October 2011

Jupiter Broadcasting App

Ok so this is going to be my first post. I never really blogged before but I wanted a outlet for some of the cool and not so cool little projects that I do (mainly to do with software). Anyway, last Thursday I was watching Linux Action Show and TechSnap. Which are awesome by the way. I heard someone in the chatroom say that there was an iphone app but not an android app. I really think that is because you don't really need an android app with all the apps in the market place to stream content and to get rss feeds but I made this anyway because its annoying to keep hearing people say things like that and it will be a good educational piece of code for people starting off with android.

Lets get started, so first thing I did was decide to play the audio stream. So I created a media player object and set the data source to mp3 stream from jblive.am. Then I created a quick GUI, just a button using drag and drop with eclipse. Then I linked the button to a listener like this


play.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
if(!mp.isPlaying()){
         mp.setDataSource("http://64.150.176.9:8232");
mp.prepare();
         mp.start();
         play.setText("Pause");
}else{
mp.stop();
         play.setText("Play");
}

}
     
        });
    }

where play is the button Object. So I gave the chat room a link and was told they liked it but was asked if could I add ongoing app notifications. I went rummaging through the android docs to find out how to do this, turns out its not that hard. So I set the notifications on the on Pause listener like this


@Override protected void onPause() {
   super.onPause();
   {
  String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
  if(mp.isPlaying()){
Notification notification = new Notification(R.drawable.icon, "Jupiter Broadcasting",System.currentTimeMillis());

Intent notificationIntent = new Intent(this, Home.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent intent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(getApplicationContext(),"Jupiter Broadcasting", "Playing Live Stream", intent);

notification.flags = Notification.FLAG_ONGOING_EVENT ;
mNotificationManager.notify(34,notification);
  }else{
      mNotificationManager.cancel(34);
      }
   }
    }


The "mNotificationManager.cancel(34);" is very important to stop the notification appearing unintentionally. By this stage we have a relatively functional radio app and I started thinking about new features that could be useful and I remembered I had some code for an RSS reader that I grabbed from someones blog and modified slightly so I added the feed for all shows so that people can download the latest episodes.

I'm just about finished but I'll probably update and add stuff to this over time but its pretty much done. I'd also like to point out that while most of the code is mine(The RSS reader part isn't I've been trying to find the blog I took it from however I have modified it to click into links) and feel free to use it whatever way you want. The images I don't know what sort of copy right there is about the images and if Chris or anyone else from jupiter broadcasting wants me to take this down or remove or modify it. I will without issue. Hope you enjoyed my first blog(Although it was probably boring as sin sorry :))



Here is the code and the apk
Source Code (Eclipse Project)
APK

Update its in the android market now : https://play.google.com/store/apps/details?id=jupiter.broadcasting.live.tv

16 comments:

  1. Well done!!! Have it installed and will use it for the next show :-) . Made a QR code for you:
    http://qr.insready.com/node/103

    ReplyDelete
  2. Thanks dude and I chuck the qr code up with my next post. By the way if you have any issues let me know. I'm slightly worried about how it scales on tablets because my testing device is so small and emulators are not always the best.

    ReplyDelete
  3. Apk link seems to be down. Can reupload please?
    Thanx
    Tzvi

    ReplyDelete
  4. Its not down for me now. I suggest trying again. If you still can't get it. I'll put it on either some other file sharing site or my ftp server. I'll be putting into the market within the next week or so anyway

    ReplyDelete
  5. Strange for me it still isn't working. Maybe Chris can host yhr apk for you...

    Thanks for the effort and time!

    ReplyDelete
  6. Here is a link to the file on my server I'll be taking this down eventually unlike the ubuntu one link. Also if any else has any issues with the link let me know

    csserver.ucd.ie/~09489207/JupiterBroadcasting.apk

    ReplyDelete
  7. I can't seem to download this from my Archos tablet, link does nothing.

    ReplyDelete
  8. Ok just tried it on my droid long click the link until a menu pops up and then press save link and the apk should start downloading. If that doesn't work try downloading it on the computer and putting it on the device through bluetooth or sd card

    ReplyDelete
  9. The app gives me an IOException on loading the rss feed, and I can't figure out why.

    ReplyDelete
  10. nightfox, What device do you have? Does the rest of the app function correctly? And can you give me exact steps to reproduce.

    Also there maybe the slightest possibility the file got corrupted when you downloaded here is the md5 if you would like to check it.

    5a1bb478ddf744968f52928c10ad5c4d

    ReplyDelete
  11. I have a samsung galaxy S II with litening rom. Everything works except for the rss reader in the original app (installed for the apk, md5 is the same and I uninstalled, redownloaded and reinstalled as well). After downloading the code and changing the code for diagnostics, I changed this:
    catch (IOException e) {
    textView.setText("IOException");
    }
    I get a list full of IOException in rss reader. I've tried debugging to look for the error, but I guess I'm not skilled enough to find it.

    ReplyDelete
  12. The code I posted above was in the class RssListAdapter.java by the way

    ReplyDelete
  13. Cool I have a friend with an S2 and a custom rom on it so I run it on his device next time I talk to him and see if I can debug it with log cat. I'll let you know what I come with

    ReplyDelete
  14. Hope to see it soon in the market

    ReplyDelete
  15. It will be Melroy. I have to finish my exams then I'll tidy up the look at fell of it and put it on the market. It will be free by the way and I'll post the updated code here. Sorry it taking so long but I originally gave it to Chris to put on the market so that jupiter broadcasting could use it as a source of income but he hasn't been able to find the time to do it. So it will be up there some time in the next few weeks.

    ReplyDelete