media icon indicating copy to clipboard operation
media copied to clipboard

ConcatenatingMediaSource to ConcatenatingMediaSource2

Open rbinek opened this issue 2 years ago • 1 comments

I have a list of files and for each of those file I create MediaSource like

                MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
                        .createMediaSource(
                                MediaItem.fromUri(
                                Uri.fromFile(new File("path_to_file")))
                                        .buildUpon()
                                        .setMediaMetadata(mediaMetadata)
                                        .setTag(filesList.getNpPodKolko())
                                        .build()
                        );

and then I add this to

concatenatingMediaSource.addMediaSource(mediaSource);

where concatenatingMediaSource is defines as follows: ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource();

I want to migrate this to ConcatenatingMediaSource but I get the error: Progressive media source must define an initial placeholder duration

How can I calculate the desired placeholder duration ?

rbinek avatar Feb 17 '24 22:02 rbinek

How can I calculate the desired placeholder duration ?

You can't. The library would calculate it for you if the duration was available at this moment. The library must load the source first to know it's duration, so you have to give a placeholder until this happens.

As an side: ConcatentatingMediaSource2 is not a replacement for ConcatenatingMediaSource. If you want to migrate away from the deprecated ConcatenatingMediaSource, I'd look into the playlist API instead which is the successor of the ConcatenatingMediaSource API.

marcbaechinger avatar Feb 19 '24 10:02 marcbaechinger