Android - Track info Nombre y Artista

   
Vista:

Track info Nombre y Artista

Publicado por marcelo (3 intervenciones) el 09/09/2015 21:13:31
alguien me puede ayudar estoy tratando de obtener datos del artista y nombre de canción pero no me funciona
gracias


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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import java.io.IOException;
import java.lang.String;
 
 
public class MainActivity extends ActionBarActivity {
 
 
    private Button playBoton, pauseBoton, exitBoton;
    public String url = "http://mimix.mercurio.cl:8000/digitalfm";
    public MediaPlayer mediaPlayer;
 
    public static final String SERVICECMD = "com.android.music.musicservicecommand";
    public static final String CMDNAME = "command";
    public static final String CMDTOGGLEPAUSE = "togglepause";
    public static final String CMDSTOP = "stop";
    public static final String CMDPAUSE = "pause";
    public static final String CMDPREVIOUS = "previous";
    public static final String CMDNEXT = "next";
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
 
 
        setContentView(R.layout.activity_main);
 
 
 
        playBoton       = (Button)  findViewById(R.id.bt_play);
        pauseBoton      = (Button)  findViewById(R.id.bt_pausa);
        exitBoton       = (Button)  findViewById(R.id.bt_salir);
 
        playBoton.setOnClickListener(new View.OnClickListener() {
 
            @Override
            public void onClick(View v) {
 
 
                if (mediaPlayer != null)
                    mediaPlayer.release();
 
                mediaPlayer = new MediaPlayer();
                mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
 
                try {
                    mediaPlayer.setDataSource(url);
                } catch (IOException e) {
                    e.printStackTrace();
                }
 
                try {
                    mediaPlayer.prepare(); // might take long! (for buffering, etc)
                } catch (IOException e) {
                    e.printStackTrace();
                }
 
                if (!mediaPlayer.isPlaying()) {
                    mediaPlayer.start();
                }
 
            }
 
 
        });
 
 
 
 
 
 
 
        IntentFilter iF = new IntentFilter();
        iF.addAction("com.android.music.metachanged");
 
        iF.addAction("com.htc.music.metachanged");
 
        iF.addAction("fm.last.android.metachanged");
        iF.addAction("com.sec.android.app.music.metachanged");
        iF.addAction("com.nullsoft.winamp.metachanged");
        iF.addAction("com.amazon.mp3.metachanged");
        iF.addAction("com.miui.player.metachanged");
        iF.addAction("com.real.IMP.metachanged");
        iF.addAction("com.sonyericsson.music.metachanged");
        iF.addAction("com.rdio.android.metachanged");
        iF.addAction("com.samsung.sec.android.MusicPlayer.metachanged");
        iF.addAction("com.andrew.apollo.metachanged");
 
        registerReceiver(mReceiver, iF);
 
    }
 
 
    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
 
        @Override
        public void onReceive(Context context, Intent intent)
        {
            String action = intent.getAction();
            String cmd = intent.getStringExtra("command");
 
            String artist = intent.getStringExtra("artist");
            String album = intent.getStringExtra("album");
            String track = intent.getStringExtra("track");
            Log.d("Music",artist+":"+album+":"+track);
        }
    };
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