unfortunately I'm unable to set metadata such as "TITLE" or "ARTIST" for a track which I'm streaming from soundcloud in an external musicplayer.
This is how I thought it should work:
Uri uri = Uri.parse("http://api.soundcloud.com/tracks/135150341/stream?client_id=MY_SECRET_CLIENT_ID");
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, "BLA");
it.putExtra(MediaStore.Audio.Media.TITLE, "TEST TITLE");
it.putExtra(MediaStore.Audio.Media.ARTIST, "TEST ARTIST");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);
After this part I can choose my favorite player and it'll start playing the track,
but I cannot set the metada... I don't see any name of the artist or the track or anything...
Is there any way to set the metadata for this audio stream?
Or to get the metadata from soundcloud directly?
Thanks in advance,
Marcus
Looks like that the streamed mp3 file does not have the metadata.
You can access all data available using following api call:
http://api.soundcloud.com/tracks/135150341.json?client_id=10fe52a882bf103b82641c33870f6500
Related
My App is having audio files in raw folder. Now whenever app gets launched these audio files should play using default music player. I tried below code App is crashing with "No Activity found to handle this intent".
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("companion.harman.com.ceshuclient/res/raw/fav.mp3"), "audio/*");
startActivity(intent);
The same audio files can be played using "MediaPlayer" object but that is not what exactly I'm trying to acheive.
Any sample code or links can be helpful.
Thanks in Advance.
Please try the following (Where mp3file is the name of the file in the raw folder without extension. Use only lowercase characters, please):
MediaPlayer player = MediaPlayer(this,R.raw.mp3file);
player.prepare();
player.start();
player.stop();
player.reset();
player.release();
player = null;
Here is the link of demo source code to play mp3 File
I want to open video file and set the previewed title in video player with a different title than the file name (which is used by default).
String videoFile = "Video file url / path";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(videoFile), "video/mp4");
// Is there an extra to set the previewed video title?
mMainActivity.startActivity(intent);
There is no documented extra for ACTION_VIEW that would offer this, and third-party video players would not have to honor it anyway. You are welcome to implement your own video player in your own app if you wish to control the title.
I am using this snippet to open a video using default Android Video Player:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://my.video/link.mp4"), "video/mp4");
startActivity(intent);
Now I want to display subtitle on the video, my subtitle is provided with a url, example http://my.subtitle/link.srt. I think there would be something simple like this:
intent.putExtra("subtitle", "http://my.subtitle/link.srt");
But it doesn't seem to be simple like that.
Could anyone show me how to do it? Thanks a lot.
I have app where I have url of media file.
I wish if I could start Music and Video app and play file.
Is there any chance to do that.
I dont want to write my own media player app.
Create an ACTION_VIEW intent with the path to your media file and include the type of media you want to play.
String audioPath = "path/to/audio.mp3";
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
// set the data and type, for movies this would be video/*
intent.setDataAndType(Uri.parse(audioPath), "audio/*");
getContext().startActivity(intent);
You don't have to set the type, but I would suggest doing so. Setting the type will limit the activities to activities that know how to handle the given type.
I have an application that plays video files.
I have been using code for using Videoview and starting the Videoview manually to play video files. However, I just wanted to know if I can use the default media player or video player of android rather than creating or using the VideoView to play the file..
Please make comments if the question is not clear.
Thanks alot
Sure - just use an Intent with the file Uri.
File file = new File("fileUri");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);