-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
Description
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.

Reactions are currently unavailable