Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultTimeBar doesn't show the progress #3926

Closed
prilaga opened this issue Mar 2, 2018 · 5 comments
Closed

DefaultTimeBar doesn't show the progress #3926

prilaga opened this issue Mar 2, 2018 · 5 comments
Assignees

Comments

@prilaga
Copy link

prilaga commented Mar 2, 2018

Hi, I have purpose to play video from different sources. From network (DASH) I see the progress of seekbar, but when the source is a file - not.
It happened on every time if I try to play from file. I tried different mp4 files.

Seems problem that player can't detect the total length of the video.
How to resolve this issue?

exoplayer v.2.7.0
sony z5, android 7.1.1

any video file can be used, just replace "file_path" with real path.

video for testing: https://www.dropbox.com/s/3y7w8c0e5j1aukt/17900053588159454.mp4?dl=0

code:

            val bandwidthMeter = DefaultBandwidthMeter()

            val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(bandwidthMeter)
            val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
            val player = ExoPlayerFactory.newSimpleInstance(this, trackSelector)

            binding.exoPlayer.player = player
            player.playWhenReady = true

            val videoFile = File("file_path")
            val uri = Uri.fromFile(videoFile)
            val dataSpec = DataSpec(uri)
            val fileDataSource = FileDataSource(bandwidthMeter)
            fileDataSource.open(dataSpec)
            val factory: DataSource.Factory = DataSource.Factory { fileDataSource }
            val mediaSource = ExtractorMediaSource.Factory(factory).createMediaSource(fileDataSource.uri, Handler(), null)
            player.prepare(mediaSource)

On the left side - progress time, on the right - total time.
device-2018-03-02-133550

@erdemguven
Copy link
Contributor

Please provide complete information as requested in the issue template. The issue template can be found here.

@erdemguven erdemguven self-assigned this Mar 2, 2018
@prilaga
Copy link
Author

prilaga commented Mar 2, 2018

Hi @erdemguven , I updated the info. Please let me know if I something missed.

Also I able to get the length of the video by next way:

val videoFile = File("file_path")
val retriever =  MediaMetadataRetriever();
retriever.setDataSource(context, Uri.fromFile(videoFile));
val time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
val timeInMillisec = time.toLong()
retriever.release()

@erdemguven
Copy link
Contributor

The given mp4 file header doesn't contain the duration. ExoPlayer relays on the information provided in the header. You might try to re encode the file.

@ojw28
Copy link
Contributor

ojw28 commented Mar 2, 2018

It's true that the duration is for some reason set to 0 in the sample file (it probably shouldn't be). However it should be possible for us to fill in the missing duration based on the stbl atom in order to handle this case.

@prilaga
Copy link
Author

prilaga commented Mar 2, 2018

It will be great if ExoPlayer will be able to count the duration for files with empty/bad headers. In other case developers need to recreate video file and only then pass to player.

ojw28 added a commit that referenced this issue Mar 7, 2018
Issue: #3926

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188020756
ojw28 added a commit that referenced this issue Mar 7, 2018
Issue: #3926

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188020756
@ojw28 ojw28 closed this as completed Mar 28, 2018
@google google locked and limited conversation to collaborators Aug 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants