Android İnternet Radiosu Yapımı
-
android de internet radyosu yapmaya çalışıyorum başardım aslında bri radyoyu bağladım ama play butonuna tıklayınca 12-13 sn sonra başlıyor yayın bu süreyi nasıl kısaltabilirim
-
asiminnesli bunu yazdı
android de internet radyosu yapmaya çalışıyorum başardım aslında bri radyoyu bağladım ama play butonuna tıklayınca 12-13 sn sonra başlıyor yayın bu süreyi nasıl kısaltabilirim
Hocam Kodlarını alabilme şansım var mı ? Gitte falan geliştiriyorsan ?
-
MhmdAlmz bunu yazdıasiminnesli bunu yazdı
android de internet radyosu yapmaya çalışıyorum başardım aslında bri radyoyu bağladım ama play butonuna tıklayınca 12-13 sn sonra başlıyor yayın bu süreyi nasıl kısaltabilirim
Hocam Kodlarını alabilme şansım var mı ? Gitte falan geliştiriyorsan ?
github tan direk yürüttüm hocam kodları
buyur kodlar
package com.example.asim.radio;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.RemoteViews;
import org.w3c.dom.Text;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import static com.example.asim.radio.R.layout.test;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private final static String RADIO_STATION_URL = "http://95.173.184.17:9974/";
private Button buttonPlay;
private Button buttonStopPlay;
private Button buttonNotification;
private MediaPlayer player;
int isPlaying;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//intetn olarak dönünce
Bundle extraData = getIntent().getExtras();
initializeUIElements();
initializeMediaPlayer();
}
private void initializeUIElements() {
buttonPlay = (Button) findViewById(R.id.buttonPlay);
buttonPlay.setOnClickListener(this);
buttonNotification = (Button) findViewById(R.id.buttonNot);
buttonNotification.setOnClickListener(this);
}
public void onClick(View v) {
if (v == buttonPlay) {
if(isPlaying==1){
stopPlaying();
}else {
startPlaying();
notificationYollaCustom();
}
}
}
public void startPlaying() {
isPlaying=1;
player.prepareAsync();
player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player.start();
}
});
}
public void notificationYollaCustom() {
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.widget);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.not).setContent(
remoteViews);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, yeni.class);
// The stack builder object will contain an artificial back stack for
// the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(yeni.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.button1, resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(100, mBuilder.build());
}
public void stopPlaying() {
isPlaying=0;
player.stop();
player.release();
initializeMediaPlayer();
}
public void initializeMediaPlayer() {
player = new MediaPlayer();
try {
player.setDataSource(RADIO_STATION_URL);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void onPause() {
super.onPause(); // Always call the superclass method first
}
} -
Internetten kaynaklı gecikmedir bence başka birşey gözükmüyor
-
aynen tlf modelinde etkili olabilir.
-
Mobildeyim Kodlara bakmadım ama mantığını söyleyeyim play yapmadan önce bir limite kadar stream yapar yani yayın verisini indirir mesela 300kb lik veri inince play yap dersin böylece sen 300kblik veriyi dinlerken başka 300kblik veri inmiş olur başlangıç süresini kısaltmak istiyorsan o limiti bulup azaltmalısın