How to get the entire content Duration of a MediaItem, not just the clip length?
See original GitHub issue[REQUIRED] Question
I have a list of MediaItem
s with different start positions.
MediaItem mediaItem = new MediaItem.Builder()
.setUri(trackUri)
.setClipStartPositionMs(startPos)
.setClipEndPositionMs(C.TIME_END_OF_SOURCE)
.build();
When a particular MediaItem is being played, the Player is just returning the duration of the clip, not the total length of the track. Is there a way where I can get the total length of the track, not just the clip length?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to get duration of a video file? - android - Stack Overflow
I'm writing an application to list all video file in a folder and display information of all videos in the folder. But when...
Read more >REST Resource: mediaItems | Google Photos APIs
Metadata that is specific to a photo, such as, ISO, focal length and exposure time. Some of these fields may be null or...
Read more >Setting the duration of a video file in C# - MSDN - Microsoft
I want to change the duration to reflect the total length of both files. Any suggestions are appriciated. p.s not using ffmpeg.
Read more >Display the duration, current time, and remaining time of the ...
Wait for the player to be in at least the PREPARED state. Retrieve the current playhead time by using the MediaPlayer.getCurrentTime method.
Read more >Working with Media - ProPresenter User Guide
If you have multiple Media Actions selected at the same time, ... Scale to Fit will make sure that all of your content...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pavan245 - For only changing the start clip position, my solution posted above will work. For the end position, marking this as a duplicate of #3163 as per Toni’s response above.
If you’re only changing the start clip position then I think you can retrieve the entire content duration like:
Note that you can also retrieve the timeline from
Player.getCurrentTimeline
. @pavan245 - Does that work for you?The same trick does not work if you set an end clip position, however. This may not be relevant to your use case, but is something we should think about. @tonihei - Do you understand why that’s not the case? If both start and end are clipped, I think I’d expect the period and window to look like:
where-as it seems they look like:
I tried changing
ClippingTimeline.getPeriod
to do what I expected, but then playback doesn’t transition to the ended state once the clip end point is reached. Which also seems unexpected to me.