标签: android-music-player

没有获得流派的拇指 - 环球音乐播放器

我使用UMPGoogle提供的示例,我的代码没有做任何更改,即使我没有尝试任何开箱即用的东西,我只是将您的项目导入我的工作区并在我的设备上进行了检查,发现我am not getting Thumb with Genres(流派歌曲)和流派列表......

虽然我应该从我们的JSON获得Thumb,但这是我尝试过的(但没有成功) -

holder.mImageView.setImageBitmap(description.getIconBitmap());
Run Code Online (Sandbox Code Playgroud)

更新#1 AS PER建议的@NageshSusarla 这里

      holder.mTitleView.setText(description.getTitle());
      holder.mDescriptionView.setText(description.getSubtitle());

        AlbumArtCache cache = AlbumArtCache.getInstance();
        Bitmap art = cache.getIconImage(url);
        if (art == null) {
            cache.fetch(url, new AlbumArtCache.FetchListener() {
                @Override
                public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) {
                    if (artUrl.equals(url)) {
                        holder.mImageView.setImageBitmap(icon);
                    }
                }
            });
        } else {
            holder.mImageView.setImageBitmap(bitmap);
        }

     holder.mImageView.setImageBitmap(description.getIconBitmap());
Run Code Online (Sandbox Code Playgroud)

并得到 Cannot resolve symbol 'url'

android json audio-player android-music-player android-layout android-resources

8
推荐指数
1
解决办法
423
查看次数

Android音乐播放器小部件

我正在制作音乐播放器小部件(主屏幕小部件)..它只需播放1首歌曲(最好使用MediaPlayer类).但我不确定如何实现它.我对Android开发缺乏经验,就这么说了.

到目前为止AppWidgetProvider,我已经扩展了这个课程,我想让这个课程处理音乐播放部分并不是一个好主意Service.如果是这样,怎么样?

此外,我有3个按钮:播放,暂停和停止,我可以区分哪个按下了onReceive(...).

提前致谢!


这是班级.

public class MusicManager extends AppWidgetProvider {

    private final String ACTION_WIDGET_PLAY = "PlaySong";
    private final String ACTION_WIDGET_PAUSE = "PauseSong";
    private final String ACTION_WIDGET_STOP = "StopSong";   
    private final int INTENT_FLAGS = 0;
    private final int REQUEST_CODE = 0;

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {

        RemoteViews controlButtons = new RemoteViews(context.getPackageName(),
                R.layout.main);

        Intent playIntent = new Intent(context, MusicService.class);

        Intent pauseIntent = new Intent(context, MusicService.class);

        Intent stopIntent = new Intent(context, …
Run Code Online (Sandbox Code Playgroud)

android widget android-music-player

7
推荐指数
1
解决办法
8171
查看次数

如何使用ContentResolver创建新的播放列表

我正在尝试创建一个新的Playlist,使用Android ContentResolver,将添加到音乐播放器的播放列表中,但是当代码运行时,插入播放列表会返回null(对于Uri),当我检查音乐播放器的播放列表时,我的新Playlist条目不在那里.我怀疑insert()返回null 的原因是因为我没有正确创建播放列表.有人可以澄清如何动态创建新的播放列表,因为我的代码不起作用.(在我的搜索中,我找到了几种查询播放列表的方法,但实际上并没有创建新的播放列表)

这是我的代码......

    ContentResolver resolver = getActivity().getContentResolver();

    Uri playlists = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;

    Log.d(A.TAG, "Checking for existing playlist for " + chart.getName());
    Cursor c = resolver.query(playlists, new String[] {"*"}, null, null, null);
    long playlistId = 0;
    c.moveToFirst();
    do {
        String plname = c.getString(c.getColumnIndex(MediaStore.Audio.Playlists.NAME));
        if (plname.equalsIgnoreCase(chart.getName())) {
            playlistId = c.getLong(c.getColumnIndex(MediaStore.Audio.Playlists._ID));
            break;
        }
    } while (c.moveToNext());
    c.close();

    if (playlistId!=0) {
        Uri deleteUri = ContentUris.withAppendedId(playlists, playlistId);
        Log.d(A.TAG, "REMOVING Existing Playlist: " + playlistId);

        // delete …
Run Code Online (Sandbox Code Playgroud)

android android-music-player android-contentprovider

7
推荐指数
1
解决办法
9067
查看次数

如何让用户在Android上查看和播放他们已经访问过的歌曲(例如,通过Google Play)?

我遇到了将音乐整合到我的Android应用中的障碍.目标只是让用户通过Google Play音乐(或任何其他播放器,如Winamp,Poweramp,doubleTwist等)查看和播放他们已经访问过的歌曲.

到目前为止,我已经尝试了几种方法,但每种方法都存在问题.

方法#1:使用ContentResolver查询从Google Play音乐中获取播放列表和歌曲,然后使用MediaPlayer播放

首先,在播放列表上获取光标:

String[] proj = { MediaStore.Audio.Playlists.NAME,
                  MediaStore.Audio.Playlists._ID };
Uri playlistUri = Uri.parse("content://com.google.android.music.MusicContent/playlists");
Cursor playlistCursor = getContentResolver().query(playlistUri, proj, null, null, null);
Run Code Online (Sandbox Code Playgroud)

然后迭代以获取每个播放列表中的歌曲,并按如下方式读取它们:

String[] proj2 = { MediaStore.Audio.Playlists.Members.TITLE,
                   MediaStore.Audio.Playlists.Members._ID };
String playListRef = "content://com.google.android.music.MusicContent/playlists/" + playListId + "/members";
Uri songUri = Uri.parse(playListRef);
Cursor songCursor = getContentResolver().query(songUri, proj2, null, null, null);
Run Code Online (Sandbox Code Playgroud)

这可以获取播放列表和歌曲,但实际上您无法播放它们(即使您将Google Play音乐告诉"保留在设备上").具体来说,以下代码不播放如上所示的给定歌曲:

mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
    mediaPlayer.setDataSource(dataPath);
    mediaPlayer.prepare();
    mediaPlayer.start();
} catch (Exception e) {}
Run Code Online (Sandbox Code Playgroud)

事实上,我已经扫描了设备,并且无法在任何地方找到这些文件(尽管我已经通过完全禁用网络确认它们是本地的 - 在Galaxy Nexus和Galaxy S3上).

方法#2:使用Intent调用Google Play音乐或其他播放器

根据这篇文章,您可以使用Intents简单地调用播放器,如下所示: …

android android-intent android-music-player android-contentprovider google-play

7
推荐指数
1
解决办法
2440
查看次数

SlidingUpPanelLayout无法正确使用CoordinatorLayout作为SlidingUpPanelLayout的第一个子节点

因此,当fitssystemwindow在拍摄时为真,它会自动增加其面板高度,当它为假时它可以正常工作.但在我的项目中,我需要这样的,所以请给我任何解决方案;

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"
android:layout_height="match_parent"
 >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slideUpLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"

    sothree:umanoDragView="@+id/dragView"
    sothree:umanoOverlay="true"
    sothree:umanoPanelHeight="68dp"
    sothree:umanoParallaxOffset="100dp"
    sothree:umanoShadowHeight="4dp">
    <!-- This is the first child  and show main content-->
    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout       
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" // when this is false work fine otherwise     not
 >

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay">

    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom" …
Run Code Online (Sandbox Code Playgroud)

android android-music-player android-coordinatorlayout

7
推荐指数
0
解决办法
284
查看次数

Android音乐播放器的通知

如何从通知中的按钮控制音乐播放器,以及如何从通知中收听按钮操作

notifications android audio-player android-music-player remoteview

6
推荐指数
1
解决办法
1万
查看次数

如何在Android 4.4 KitKat带有元数据的SD卡上向MediaStore添加媒体

背景:在Android 4.4中,Google决定应用程序不应具有对SD卡的写入权限.

但是,应用程序可以写入/ SDCard/Android/data/App Package Name.

所以这就是我所做的.我已经写了一个MP3文件到/ Android/data /.然后我希望这个MP3文件出现在Android音乐播放器中.

我试过以下......

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
            + filePath))); 

和....

    MediaScannerConnection.scanFile(this,
          new String[] { file.toString() }, new String[] {"audio/*"},
          new MediaScannerConnection.OnScanCompletedListener() {
      public void onScanCompleted(String path, Uri uri) {
          Log.i("ExternalStorage", "Scanned " + path + ":");
          Log.i("ExternalStorage", "-> uri=" + uri);
      }
 });

和...

ContentResolver.requestSync(CreateSyncAccount(context), MediaStore.AUTHORITY, null);

这两个文件都会将文件作为文件添加到MediaStore,文件内容为:media/external/file/xxxxx

但是,该文件不会添加为音频.我可以更新MediaStore以将文件声明为音频,但不导入文件元数据.

除了编写我自己的标签阅读器之外,如何让媒体扫描仪扫描文件并像在内存和预KitKat SD卡上一样插入元数据?

android audio-player android-music-player android-sdcard android-mediascanner android-4.4-kitkat

6
推荐指数
1
解决办法
3462
查看次数

MediaMetadata.getString java.lang.RuntimeException:无法从parcel blob读取位图

调用MediaMetadata.getString,在报告中有以下崩溃,但并不总是重复:

 java.lang.RuntimeException: Could not read bitmap from parcel blob.
    at android.graphics.Bitmap.nativeCreateFromParcel(Native Method)
    at android.graphics.Bitmap.access$000(Bitmap.java:32)
    at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:1477)
    at android.graphics.Bitmap$1.createFromParcel(Bitmap.java:1469)
    at android.os.Parcel.readParcelable(Parcel.java:2246)
    at android.os.Parcel.readValue(Parcel.java:2146)
    at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
    at android.os.BaseBundle.unparcel(BaseBundle.java:221)
    at android.os.BaseBundle.getCharSequence(BaseBundle.java:953)
    at android.os.Bundle.getCharSequence(Bundle.java:716)
    at android.media.MediaMetadata.getText(MediaMetadata.java:334)
    at android.media.MediaMetadata.getString(MediaMetadata.java:347)
Run Code Online (Sandbox Code Playgroud)

代码就像吹,MediaMetadata元是来自api MediaSessionManager.OnActiveSessionsChangedListener的控制器,它应该由第三方音乐应用程序创建.

    meta.getString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST);
    meta.getString(MediaMetadata.METADATA_KEY_ARTIST);            
    meta.getString(MediaMetadata.METADATA_KEY_AUTHOR);         
    meta.getBitmap(MediaMetadata.METADATA_KEY_ART);
    meta.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);            
    meta.getString(MediaMetadata.METADATA_KEY_ALBUM);
    meta.getString(MediaMetadata.METADATA_KEY_TITLE);
Run Code Online (Sandbox Code Playgroud)

为什么getString将解析位图?当这种情况发生时,内存是否可能出局?

java android bitmap android-music-player

6
推荐指数
1
解决办法
1282
查看次数

如何在Android Oreo中显示媒体的彩色通知?

在此输入图像描述

正如您已经知道Android Oreo引入了媒体控件的新设计,而不是根据应用程序的颜色通知选择单一颜色,媒体播放通知可以改为从专辑图片中绘制颜色.然后,Android会使用这些颜色发出通知,将图稿混合到通知中,同时使通知本身在通知阴影中弹出.

我可以知道我们怎么做到这一点吗?

android android-music-player android-layout android-notifications

6
推荐指数
1
解决办法
2797
查看次数

如何更新 Android Q 媒体商店中音频文件的元数据?

更新媒体商店中音频文件的元数据不适用于 Android Q 操作系统,它适用于所有其他操作系统。

我正在使用 uri 指定为 MediaStore.Audio.Media.EXTERNAL_CONTENT_URI 的内容提供程序。它在所有低于 Android Q 的设备上运行良好。下面是我用来更新轨道元数据的代码。

ContentValues cv = new ContentValues();
ContentResolver resolver = getContentResolver();
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

cv.put(MediaStore.Audio.Media.TITLE, newTitle);
cv.put(MediaStore.Audio.Media.ALBUM, newAlbumName);
cv.put(MediaStore.Audio.Media.ARTIST, newArtistName);

int rowsUpdated = resolver.update(uri, cv, 
MediaStore.Audio.Media._ID + " = ? ", new String[]{audioId});
Run Code Online (Sandbox Code Playgroud)

对于 Android Q 设备,rowsUpdated 始终为 0,无一例外。其他音乐播放器如何更新 Android Q 中的曲目元数据?

android mediastore android-music-player android-contentprovider android-10.0

6
推荐指数
2
解决办法
3101
查看次数