Android 尝试使用ExoPlayer播放RTMP流

Android 尝试使用ExoPlayer播放RTMP流,android,video-streaming,rtmp,exoplayer,Android,Video Streaming,Rtmp,Exoplayer,我有以下代码: SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(this); PlayerView playerView = findViewById(R.id.simple_player); playerView.setPlayer(player); RtmpDataSourceFactory rtmpDataSourceFactory = new RtmpDataSourceFactory();

我有以下代码:

SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(this);
    PlayerView playerView = findViewById(R.id.simple_player);
    playerView.setPlayer(player);

    RtmpDataSourceFactory rtmpDataSourceFactory = new RtmpDataSourceFactory();
 MediaSource videoSource = new ProgressiveMediaSource.Factory(rtmpDataSourceFactory)
            .createMediaSource(Uri.parse("https://player.cdnmedia.tv/embed/a77aa67c"));
player.prepare(videoSource);
player.setPlayWhenReady(true);
这是我的渐变文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "my.company.streaming"
    minSdkVersion 26
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.exoplayer:exoplayer:2.10.3'
implementation 'com.google.android.exoplayer:extension-rtmp:2.7.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
我的stacktrace崩溃了:

java.lang.AbstractMethodError: abstract method "void com.google.android.exoplayer2.upstream.DataSource.addTransferListener(com.google.android.exoplayer2.upstream.TransferListener)"
    at com.google.android.exoplayer2.source.ProgressiveMediaSource.createPeriod(ProgressiveMediaSource.java:246)
    at com.google.android.exoplayer2.source.ExtractorMediaSource.createPeriod(ExtractorMediaSource.java:354)
    at com.google.android.exoplayer2.MediaPeriodHolder.createMediaPeriod(MediaPeriodHolder.java:417)
    at com.google.android.exoplayer2.MediaPeriodHolder.<init>(MediaPeriodHolder.java:92)
    at com.google.android.exoplayer2.MediaPeriodQueue.enqueueNextMediaPeriod(MediaPeriodQueue.java:149)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeUpdateLoadingPeriod(ExoPlayerImplInternal.java:1623)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.updatePeriods(ExoPlayerImplInternal.java:1492)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:552)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:326)
    at android.os.Handler.dispatchMessage(Handler.java:101)
    at android.os.Looper.loop(Looper.java:164)
    at android.os.HandlerThread.run(HandlerThread.java:65)

AbstractMethodError
AbstractMethod“void com.google.android.exoplayer2.upstream.DataSource.addTransferListener(com.google.android.exoplayer2.upstream.TransferListener)
意味着您必须实现抽象方法/
.addTransferListener(TransferListener)
.Class将已经实现了
接口
(这可以是任何其他实现该接口的类)

请尝试另一个构造函数:

BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);

我已经这样做了,现在我收到了“源错误”“。流媒体当前未联机,这可能是原因吗?如果我将URL粘贴到浏览器中,我会看到彩色条,而我在应用程序中看不到。我正在等待客户端启动一个测试流,看看它是否工作,如果有一些内容实际上是流的。将使用结果进行更新,如果有效,将接受答案。谢谢你的帮助。尝试在邮递员返回“无法得到任何回应”。在Postman的设置中不允许SSL认证看起来我得到了一些东西(html代码)。客户端开始流式处理,我收到了源错误。更新我的问题。
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);