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

Is it possible to play images? #2874

Closed
mrblrrd opened this issue May 27, 2017 · 1 comment
Closed

Is it possible to play images? #2874

mrblrrd opened this issue May 27, 2017 · 1 comment
Labels

Comments

@mrblrrd
Copy link

mrblrrd commented May 27, 2017

I'm trying to show .jpeg images for 5 seconds, but they are just skipped when playing. Is it correct to use SingleSampleMediaSource for that purpose? How to do it right?

void setPlaylist(List<Track> playlist) {
    MediaSource[] mediaSources = tracksToMediaSources(playlist);
    MediaSource mediaSource = (mediaSources.length == 1)
            ? mediaSources[0]
            : new ConcatenatingMediaSource(mediaSources);
    player.prepare(mediaSource);
    player.setVideoTextureView(textureView);
}

private MediaSource[] tracksToMediaSources(List<Track> playlist) {
    int playlistSize = playlist.size();
    MediaSource[] mediaSources = new MediaSource[playlistSize];
    for (int i = 0; i < playlistSize; ++i) {
        Track track = playlist.get(i);
        Uri trackUri = Uri.parse(track.getUrl());
        switch (track.getType()) {
            case VIDEO:
                mediaSources[i] = new ExtractorMediaSource(trackUri, provideDataSourceFactory(), provideExtractorsFactory(), null, null);
                break;
            case IMAGE:
//--???-->      mediaSources[i] = new SingleSampleMediaSource(trackUri, provideDataSourceFactory(), Format.createImageSampleFormat(null, "image/jpeg", null, Format.NO_VALUE, null, null, null), 5000);
                break;
        }
    }
    return mediaSources;
}
@ojw28
Copy link
Contributor

ojw28 commented May 29, 2017

We do not provide any built in support for playback of images. You could potentially write your own custom renderer (e.g. ImageRenderer extends BaseRenderer) to provide direct support within the player, or just manage displaying of images yourself outside of the player.

@ojw28 ojw28 closed this as completed May 29, 2017
@ojw28 ojw28 added the question label May 29, 2017
@google google locked and limited conversation to collaborators Sep 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants