Android - Problemas con App para Streaming

 
Vista:

Problemas con App para Streaming

Publicado por Angel Ramirez (1 intervención) el 23/07/2019 21:49:58
Hola, estaba haciendo la App para una Radio en Android studio pero cuando la abro no me muestra nada mi codigo es este:

ActivityMain:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.example.myapplication;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
 
import org.w3c.dom.Text;
 
public class MainActivity extends AppCompatActivity {
 
    //url de video para radiostar
    String videoURL = "https://66.42.108.31:5080/LiveApp/play.html?name=149162323036286491650548.m3u8";
    private ProgressDialog pd;
    VideoView videoView;
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        videoView = findViewById(R.id.videoView);
        pd = new ProgressDialog(this);
        pd.setMessage("Buffering");
        pd.setCancelable(true);
 
        playVideo();
    }
 
    private void playVideo() {
        try {
            getWindow().setFormat(PixelFormat.TRANSLUCENT);
            MediaController mediaController = new MediaController(this);
            mediaController.setAnchorView(videoView);
 
            Uri videoUri = Uri.parse(videoURL);
 
            videoView.setMediaController(mediaController);
 
            videoView.setVideoURI(videoUri);
            videoView.requestFocus();
            videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mediaPlayer) {
                    pd.dismiss();
                    videoView.start();
 
                }
            });
 
        }
        catch (Exception e){
 
            pd.dismiss();
            Toast.makeText(this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    }
}


ActivityMainXML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_gravity="center"
    tools:context=".MainActivity">
 
  <VideoView
 
      android:id="@+id/videoView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
 
      />
</LinearLayout>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder