1. Are you ready for the Galaxy S20? Here is everything we know so far!

Fragment playing audio stream

Discussion in 'Android Apps & Games' started by jfm1504, Mar 1, 2022.

  1. jfm1504

    jfm1504 Lurker
    Thread Starter

    Is it possible to have something like that working ?

    public class RadiosFragment extends Fragment implements View.OnClickListener {
    ArrayList<String> stringURL = new ArrayList<>();
    private AudioManager mAudioManager;
    MediaPlayer mp = new MediaPlayer();
    @override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    View myView = inflater.inflate(R.layout.fragment_radios, container, false);
    Button btn1 = (Button) myView.findViewById(R.id.btn1);
    btn1.setOnClickListener(this);
    return myView;
    }
    @override
    public void onClick (View myView) {
    switch (myView.getId()) {
    case R.id.btn1:
    String url="http://radioweb.com/daily.mp3";
    MediaPlayer mp = new MediaPlayer();
    mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
    //mp.setDataSource(url);
    mp.prepare();
    mp.start();
    }
    }
    }
     



    1. Download the Forums for Android™ app!


      Download

       

Android Developers

Android Developers Forum

org.chromium.webapk.abedd08025fd58b10_v2

READ MORE
Last Updated
0
Rating
Installs
Loading...
Similar Threads - Fragment playing audio
  1. 4EverNoob
    Replies:
    1
    Views:
    549
  2. paul felix
    Replies:
    1
    Views:
    728
  3. stealthrt
    Replies:
    0
    Views:
    655
  4. PeterF75
    Replies:
    0
    Views:
    853
  5. Tuxus
    Replies:
    2
    Views:
    871
  6. Kiwi_gamer01
    Replies:
    0
    Views:
    1,134
  7. Francesco10
    Replies:
    0
    Views:
    1,299
  8. Marinus Snyman
    Replies:
    4
    Views:
    2,011
  9. unet
    Replies:
    0
    Views:
    1,997
  10. Nitrogen247
    Replies:
    0
    Views:
    2,659

Share This Page

Loading...