使用ExoPlayer的播放通知中缺少getTitle,getDescription,createPendingIntent(),getLargeIcon()

时间:2019-02-17 15:47:25

标签: android audio exoplayer exoplayer2.x

我正在尝试实现Playback Notifications with ExoPlayer。但是getTitle,getDescription,createPendingIntent(),getLargeIcon丢失,并且android studio显示为红色(无法解析方法)。我如何获得这些?

我编写的代码与链接完全相同。我尝试了多次。

这是我的build.gradle文件(如果需要):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.mediaplayertest"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.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 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation "com.android.support:support-media-compat:28.0.0"
    implementation "com.android.support:support-compat:28.0.0"

    implementation 'com.google.android.exoplayer:exoplayer:2.9.5'
}

1 个答案:

答案 0 :(得分:0)

您需要正确定义gradle实现。

来自The hello world example

implementation 'com.google.android.exoplayer:exoplayer-core:2.X.X'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.X.X'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.X.X'

在gradle构建脚本中,您只需要“ exoplayer”

注意:对于PlaybackNotificationManager类,您将需要 exoplayer-ui ,这意味着您只需要该特定类  implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.5',但我还会加入 exoplayer-core