Online radio streaming app for Android
By : JanetNQ
Date : March 29 2020, 07:55 AM
To fix the issue you can do So I found this sample and it works for me, here it is if you have the same issue: in myMain.java code :
import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
public class myMain extends Activity implements OnClickListener {
private ProgressBar playSeekBar;
private Button buttonPlay;
private Button buttonStopPlay;
private MediaPlayer player;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initializeUIElements();
initializeMediaPlayer();
}
private void initializeUIElements() {
playSeekBar = (ProgressBar) findViewById(R.id.progressBar1);
playSeekBar.setMax(100);
playSeekBar.setVisibility(View.INVISIBLE);
buttonPlay = (Button) findViewById(R.id.buttonPlay);
buttonPlay.setOnClickListener(this);
buttonStopPlay = (Button) findViewById(R.id.buttonStopPlay);
buttonStopPlay.setEnabled(false);
buttonStopPlay.setOnClickListener(this);
}
public void onClick(View v) {
if (v == buttonPlay) {
startPlaying();
} else if (v == buttonStopPlay) {
stopPlaying();
}
}
private void startPlaying() {
buttonStopPlay.setEnabled(true);
buttonPlay.setEnabled(false);
playSeekBar.setVisibility(View.VISIBLE);
player.prepareAsync();
player.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player.start();
}
});
}
private void stopPlaying() {
if (player.isPlaying()) {
player.stop();
player.release();
initializeMediaPlayer();
}
buttonPlay.setEnabled(true);
buttonStopPlay.setEnabled(false);
playSeekBar.setVisibility(View.INVISIBLE);
}
private void initializeMediaPlayer() {
player = new MediaPlayer();
try {
player.setDataSource("http://usa8-vn.mixstream.net:8138");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
}
@Override
protected void onPause() {
super.onPause();
if (player.isPlaying()) {
player.stop();
}
}
}
<?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:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Source: (Radio La Chevere)"
android:layout_marginTop="10dip" android:gravity="center" />
<ProgressBar android:id="@+id/progressBar1"
android:indeterminateOnly="false" android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip" android:maxHeight="20dip"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginLeft="20dip" android:layout_marginRight="20dip"
android:layout_marginTop="10dip"></ProgressBar>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_marginTop="20dip" android:gravity="center">
<Button android:text="Play" android:id="@+id/buttonPlay"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Stop" android:id="@+id/buttonStopPlay"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package.your.RadioStream"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".myMain"
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>
|
Details needed for making an online streaming android app for an internet radio
By : Heli Rodríguez Rodrí
Date : March 29 2020, 07:55 AM
will help you You should look at this answer There are some code for how to stream a radio link. I think you want to know which information of your station you need, right? If you check the answer, there's a streaming link of the internet radio station. Every station has a streaming link like this with a port number (the four number at the end of the link).
|
Online radio streaming app for Android: where to place Wakelock and Wifilock
By : Beginner Developer
Date : March 29 2020, 07:55 AM
hope this fix your issue These attributes go in the AndroidManifest.xml file. You may need the following for your app to work correctly: code :
<android:name="android.permission.ACCESS_WIFI_STATE" uses-permission />
<android:name="android.permission.CHANGE_WIFI_STATE" uses-permission />
<android:name="android.permission.CHANGE_NETWORK_STATE" uses-permission />
<android:name="android.permission.INTERNET" uses-permission />
<android:name="android.permission.ACCESS_NETWORK_STATE" uses-permission />
// obtain wifi lock
wifiLock = ((WifiManager)
THIS_CONTEXT.getSystemService(THIS_CONTEXT.WIFI_SERVICE)).createWifiLock("clientWifiLock");
wifiLock.acquire();
|
How to play online radio streaming url in Android. How to play .pls radio streaming url in android
By : Ajeet Singh
Date : March 29 2020, 07:55 AM
Hope this helps I'll suggest you to use Service if you are creating app with MediaPlayer streaming or normal MediaPlayer. It will be easy to handle player background & centrally. To use media player in Service you can use it with BroadCastReceiver or Bound Service as per your requirement.It would be good if MediaPlayer related service if you keep it running in foreground here in below code I have not handle for that please check the given link.
|
How can I play online radio streaming in Flutter?
By : Anjali krishna
Date : March 29 2020, 07:55 AM
hop of those help? I know I am a little late to this but take a look at Fluttery Audio. A few pieces of advice that I found along the way, Android devices are not all alike, some of them will work with aac steams others will not.
|