2

I am doing shoutcast streaming in my app. The app was playing the link on android emulator 2.2 but the same was not playing in device. Why? I am using galaxy tab 2.2. Any settings required to be done? Help is appreciated. Is there any special permission required in manifest?

    public class radiog extends Activity implements
    MediaPlayer.OnCompletionListener, MediaPlayer.OnPreparedListener,
    MediaPlayer.OnErrorListener, MediaPlayer.OnBufferingUpdateListener {
private String TAG = getClass().getSimpleName();
private MediaPlayer mp = null;
private Button play;
private Button pause;
private Button stop;
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    play = (Button) findViewById(R.id.play);
    pause = (Button) findViewById(R.id.pause);
    stop = (Button) findViewById(R.id.stop);
    play.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            play();
        }
    });
    pause.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            pause();
        }
    });
    stop.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            stop();
        }
    });
}

private void play() {
    Uri myUri = Uri.parse("http://stream.radiosai.net:8020/");
    try {
        if (mp == null) {
            this.mp = new MediaPlayer();
        } else {
            mp.stop();
            mp.reset();
        }
        mp.setDataSource(this, myUri); // Go to Initialized state
        mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mp.setOnPreparedListener(this);
        mp.setOnBufferingUpdateListener(this);
        mp.setOnErrorListener(this);
        mp.prepareAsync();
        Log.d(TAG, "LoadClip Done");
    } catch (Throwable t) {
        Log.d(TAG, t.toString());
    }
}
@Override
public void onPrepared(MediaPlayer mp) {
    Log.d(TAG, "Stream is prepared");
    mp.start();
}
private void pause() {
    mp.pause();
}
private void stop() {
    mp.stop();
}
@Override
public void onDestroy() {
    super.onDestroy();
    stop();
}
public void onCompletion(MediaPlayer mp) {
    stop();
}
public boolean onError(MediaPlayer mp, int what, int extra) {
    StringBuilder sb = new StringBuilder();
    sb.append("Media Player Error: ");
    switch (what) {
    case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
        sb.append("Not Valid for Progressive Playback");
        break;
    case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
        sb.append("Server Died");
        break;
    case MediaPlayer.MEDIA_ERROR_UNKNOWN:
        sb.append("Unknown");
        break;
    default:
        sb.append(" Non standard (");
        sb.append(what);
        sb.append(")");
    }
    sb.append(" (" + what + ") ");
    sb.append(extra);
    Log.e(TAG, sb.toString());
    return true;
}
public void onBufferingUpdate(MediaPlayer mp, int percent) {
    Log.d(TAG, "PlayerService onBufferingUpdate : " + percent + "%");
}
    }
Zoot
  • 2,217
  • 4
  • 29
  • 47
user1048958
  • 371
  • 2
  • 5
  • 18
  • Without any code or further information, it is impossible to help you. Read the FAQ: http://stackoverflow.com/faq If you don't know at all where to begin, start with a packet sniffer and see if the requests to the server and responses from the server are the same. If they aren't, then figure out the differences and go from there. If they are, then you're looking at an issue with your application. – Brad Nov 30 '11 at 14:15
  • @Brad i posted my code brad plz give me suggestions.......... – user1048958 Nov 30 '11 at 14:45
  • Quite frankly, you cannot expect to get any help here, given the kinds of questions you have been asking. You asked this question yesterday (http://stackoverflow.com/questions/8252513/android-streaming-a-shoutcast-audio-file), and didn't get any response. Why did you think posting again would help? Furthermore, you didn't do what I suggested. It is up to you to narrow down the problem to a reproducible test case. It says that in the FAQ, but you have failed to read that as well. Don't waste your time, or anyone else's. Work the problem until you narrow it down. Then, post. – Brad Nov 30 '11 at 14:53
  • @Brad tnk u......myself finished the think off...and all working fine – user1048958 Dec 08 '11 at 05:36
  • You should post how you solved it in the answer box below. That's how StackOveflow works. When you solve something, you post it, so that everyone can learn. – Brad Dec 08 '11 at 14:26
  • @Brad i worked out this with android 2.3 and its works fine with same code...no change in code...... – user1048958 Dec 14 '11 at 05:34
  • So, you weren't able to fix it then? – Brad Dec 14 '11 at 14:27
  • How to play SHOUTcast?http://stackoverflow.com/a/8833346/265167 – Yaqub Ahmad Jan 12 '12 at 13:31

0 Answers0