首页 > 解决方案 > 如何在android中实现jwplayer的破折号视频流

问题描述

我有一个 jwplayer 帐户,并在那里上传了一些视频。

现在我想添加质量更改按钮,也想让播放器根据互联网选择视频质量。但是如何做到这一点

xml 文件:-

<com.longtailvideo.jwplayer.JWPlayerView xmlns:jwp="http://schemas.android.com/apk/lib/com.longtailvideo.jwplayer"
            android:id="@+id/jwplayer"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

java文件:-

mPlayerView = findViewById(R.id.jwplayer);
        PlaylistItem playlistItem = new PlaylistItem.Builder()
                .file("https://content.jwplatform.com/videos/k6Jle9TB-Ruucf9kn.mp4")
                .image("https://image.shutterstock.com/image-photo/mountains-during-sunset-beautiful-natural-260nw-407021107.jpg")
                .title("Playlist-Item Title")
                .description("Some really great content")
                .build();

        RelatedConfig related = new RelatedConfig.Builder()
                .file("https://content.jwplatform.com/videos/IHToMSjV-Ruucf9kn.mp4")
                .autoPlayTimer(5)
                .onComplete(RELATED_ON_COMPLETE_AUTOPLAY)
                .autoPlayMessage("new video will begin in 10 seconds")
                .build();

        List<PlaylistItem> playlist = new ArrayList<>();
        playlist.add(playlistItem);
        PlayerConfig config = new PlayerConfig.Builder()
                .playlist(playlist)
                .relatedConfig(related)
                .build();
        mPlayerView.setup(config);

我也想直播视频所以我想出了 DASH,它没有关于 jwplayer 文档的文档。所以从哪里开始请指导我。

标签: androidjwplayer

解决方案


您不应直接指向 JW 平台上的 MP4 资产。您应该利用他们的交付 API 并拥有一个包含所有相关数据的平台对象 - https://cdn.jwplayer.com/v2/media/k6Jle9TB

此外,让 JW 为您创建 DASH 清单需要企业合同。现在它对你没有什么好处,所以坚持使用他们在我上面链接到的提要中给你的 M3U8 (HLS) 清单。


推荐阅读