yangchaojiang / yjPlay

一个支持自定义UI布局,流式API, 加密,直播 ,亮度,音量,快进等手势 ,广告视频预览,多种加载模式 ,多种分辨率切换 ,多种封面图, 自定义数据源,列表播放,倍数播放,边播变缓存<font color="red">不是使用AndroidVideoCache</font>,离线播放,神奇的播放器
Apache License 2.0
1.73k stars 300 forks source link

Does this library support playlist mp3 #162

Open hafiz013 opened 6 years ago

hafiz013 commented 6 years ago

hi, does this library support playlist mp3 like this? music content -1

yangchaojiang commented 6 years ago

Hello. Currently, there is no single audio encapsulation. Later versions will take into account the audio package.

hafiz013 commented 6 years ago

hi, i applicable to that. The flow is that, you just make custom layout control view. Inside control view, you put design below there and list out just put recycleview on top controller view below. Lastly, in programmatically, make control view always visible. The only things, latest current version exoplayer cannot support to get each timeline as show in the picture (4.38). Hope, if anyone want to refer this as solution for their problem.

yangchaojiang commented 6 years ago

Oh I see, the duration is 4.35, not 04.35. Is my understanding right?

hafiz013 commented 6 years ago

duration is hard cord because i still cannot how to find each timeline for mp3 list music. The developer said that they will enhanced but not know when they will update.

yangchaojiang commented 6 years ago

The duration of the MP3 list can be obtained by interface and formatted by itself, if item is playing.

   .addUpdateProgressListener(new AnimUtils.UpdateProgressListener() {
                    @Override
                    public void updateProgress(long position, long bufferedPosition, long duration) {
//                     //   Log.d(TAG,"bufferedPosition:"+position);
                    //    Log.d(TAG,"duration:"+duration);
   })

Realization of monitoring,Item modifies the duration being played. default

hafiz013 commented 6 years ago

the problem is that, before load all music file I create array list which contain music title and time(hardcord). Then, i read list file directory music get name of files, url uri file list then concatenate media source. The problem current version 2.8.2 not applicable to get one by one time from file music that i extract from the directory.

yangchaojiang commented 6 years ago

Hello, recommend using content-provider to query your MP3 file information. doc

Cursor cursor = query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
歌曲ID:MediaStore.Audio.Media._ID
Int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media._ID));

歌曲的名称:MediaStore.Audio.Media.TITLE
String tilte = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));

歌曲的专辑名:MediaStore.Audio.Media.ALBUM
String album = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));

:MediaStore.Audio.Media.ARTIST
String artist = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));

:MediaStore.Audio.Media.DATA
String url = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));

:MediaStore.Audio.Media.DURATION
Int duration = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));

:MediaStore.Audio.Media.SIZE
Int size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
hafiz013 commented 6 years ago

so this cursor come from database server or ??

yangchaojiang commented 6 years ago

content-provider get content-provider Automatic reading of native database

hafiz013 commented 6 years ago

owh so meaning that, i retrieve all data from server first then store in database instead of reading from native exoplayer list timeline to get duration of mp3.

yangchaojiang commented 6 years ago

Yes, exoplayer acquisition is just the duration of the current MP3 player. In my development experience, the duration of audio and video is provided by the duration interface or by the local database, not by the exoplayer player. More than consumption memory. The experience is bad.

hafiz013 commented 6 years ago

ok note. but some suggest use this way

Timeline timeline = musicPlayer.getCurrentTimeline(); int currentWindowIndex = musicPlayer.getCurrentWindowIndex(); long currentPosition = musicPlayer.getCurrentPosition(); long totalTime = 0; Timeline.Window tmpWindow = new Timeline.Window(); if (timeline != null) { for (int i = 0; i < timeline.getWindowCount(); i++) { long windowDuration = timeline.getWindow(i, tmpWindow).getDurationMs(); timeVideo.setText(String.format("%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(currentPosition), TimeUnit.MILLISECONDS.toSeconds(currentPosition) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(currentPosition)))); //totalTime += windowDuration; //if (i < currentWindowIndex) { // currentPosition += windowDuration; //} } }

However, timeline second mp3 is zero instead of to show one by one.