首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >获取PatchStore::createDisableExceptionQarthFile方法失败

获取PatchStore::createDisableExceptionQarthFile方法失败
EN

Stack Overflow用户
提问于 2022-07-25 10:33:13
回答 1查看 153关注 0票数 0

当我突然在我的应用程序中向下滚动时,我发现这个崩溃后的应用程序崩溃了,当我想在我的音乐应用程序中显示歌曲图像时,任何一个帮助我的人都在尽力,但我找不到任何方法。

她是我的密码

代码语言:javascript
运行
复制
2022-07-24 22:05:33.942 14071-14154/com.codewithmorshed.musikc E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@41e3df3
2022-07-24 22:05:33.945 14071-14118/com.codewithmorshed.musikc E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
2022-07-24 22:06:00.418 14071-14071/com.codewithmorshed.musikc 
2022-07-24 22:06:01.086 14071-14071/com.codewithmorshed.musikc E/hmorshed.musik: [qarth_debug:]  get PatchStore::createDisableExceptionQarthFile method fail.
2022-07-24 22:06:01.089 14071-14071/com.codewithmorshed.musikc E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.codewithmorshed.musikc, PID: 14071
    java.lang.IllegalArgumentException
        at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:80)
        at com.codewithmorshed.musikc.SongAdapter.getAlbumart(SongAdapter.java:128)
        at com.codewithmorshed.musikc.SongAdapter.onBindViewHolder(SongAdapter.java:76)
        at com.codewithmorshed.musikc.SongAdapter.onBindViewHolder(SongAdapter.java:40)
        at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254)
        at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
        at androidx.recyclerview.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:288)
        at androidx.recyclerview.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:345)
        at androidx.recyclerview.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:361)
        at androidx.recyclerview.widget.GapWorker.prefetch(GapWorker.java:368)
        at androidx.recyclerview.widget.GapWorker.run(GapWorker.java:399)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

公共类RecyclerView.Adapter SongAdapter扩展了

代码语言:javascript
运行
复制
private Context mcontex;
private ArrayList<Song> msong;
RequestOptions option;
View view;
MediaPlayer mediaPlayer;


SongAdapter(Context mcontex, ArrayList<Song> msong) {
    this.mcontex = mcontex;
    this.msong = msong;

}

@NonNull
@Override
public MydViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    View view = LayoutInflater.from(mcontex).inflate(R.layout.musik_item, parent, false);
    return new MydViewHolder(view);

}




@Override
public void onBindViewHolder(SongAdapter.MydViewHolder holder,int position) {

    Song song = msong.get(position);

    holder.fillname.setText(msong.get(position).getTitel());
    holder.artistnames.setText(msong.get(position).getArtist());


    byte[] image =getAlbumart(msong.get(position).getPath());
    if (image != null) {

        Glide.with(mcontex).asBitmap().load(image).into(holder.albumpic);
    } else {
          Glide.with(mcontex).asBitmap().load(R.drawable.lastlogo).into(holder.albumpic);
       }





 holder.itemView.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {

             Intent intent = new Intent(mcontex, PlayerActivity.class);
             intent.putExtra("position", holder.getAdapterPosition());
             mcontex.startActivity(intent);

     }
 });

    // gan delete korar jonno bebhito aitar sate connected holo aikane delted file() then Song.java tha then mainActiviy.java the
    holder.songmore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PopupMenu popupMenu = new PopupMenu(mcontex,v);
            popupMenu.getMenuInflater().inflate(R.menu.song_more_layout, popupMenu.getMenu());
            popupMenu.show();
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()){
                        case R.id.Delete:
                            Toast.makeText(mcontex, "Delete", Toast.LENGTH_SHORT).show();
                            DeletedFile(holder.getAdapterPosition(),v);
                            break;
                    }
                    return true;
                }
            });


        }
    });

  }

  


private void DeletedFile(int position, View v){
    Uri contentUri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,Long.parseLong(msong.get(position).getId()));
    File file = new File(msong.get(position).getPath());
    boolean deleted = file.delete();

    if (deleted) {
        mcontex.getContentResolver().delete(contentUri,null,null);
        msong.remove(position);
        notifyItemRemoved(position);
        notifyItemRangeChanged(position, msong.size());
        Snackbar.make(v, "File Delete :", Snackbar.LENGTH_LONG).show();
    }
    else {
        Snackbar.make(v, "Undo Delete :", Snackbar.LENGTH_LONG).show();
    }

}




@Override
    public int getItemCount () {
    return msong.size();
}

public static class MydViewHolder extends RecyclerView.ViewHolder{
    private TextView fillname,artistnames;
     private ImageView albumpic,songmore;

    public MydViewHolder(@NonNull View itemView) {
        super(itemView);
        fillname = itemView.findViewById(R.id.fillname);
        albumpic = itemView.findViewById(R.id.albumpic);
        songmore = itemView.findViewById(R.id.songmore);
        artistnames = itemView.findViewById(R.id.artistnames);
    }
    }
private byte[] getAlbumart(String uri) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(uri);
    byte[] art = retriever.getEmbeddedPicture();
    retriever.release();
    return  art;



}

}

EN

回答 1

Stack Overflow用户

发布于 2022-07-25 10:48:12

MediaMetadataSource#setDataSource(String)的文档表明您的uri变量(函数getAlbumart的参数#0 )不是有效路径:

抛出:IllegalArgumentException,如果路径无效.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73107777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档