我正在使用 ExoPlayer 2.16.1,但无法导入 DefaultHttpDataSource。

huangapple go评论59阅读模式
英文:

I am using ExoPlayer 2.16.1 and I cannot import DefaultHttpDataSource

问题

我在我的项目中遇到了一个错误,错误信息是"java.lang.IllegalArgumentException: no TLS versions for cleartext connections",我需要使用"DefaultHttpDataSourceFactory"来修复它,但我无法导入它。

我的ExoPlayer版本:

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

我在哪里使用"DefaultHttpDataSourceFactory":

DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(
    Util.getUserAgent(context, "your-application-name"),
    null /* listener */,
    DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
    DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
    true /* allowCrossProtocolRedirects */
);

权限:

<uses-permission tools:node="merge" android:name="android.permission.INTERNET" />

应用程序标签:

<application
    .
    .
    .
    android:usesCleartextTraffic="true"
    .
    .
    .
>
英文:

I'm getting an error like "java.lang.IllegalArgumentException: no TLS versions for cleartext connections" in my project and I need to use "DefaultHttpDataSourceFactory" to fix it, but I can't import it.

My ExoPlayer version:

    implementation &#39;com.google.android.exoplayer:exoplayer:2.16.1&#39;
    implementation &#39;com.google.android.exoplayer:exoplayer-core:2.16.1&#39;
    implementation &#39;com.google.android.exoplayer:exoplayer-dash:2.16.1&#39;
    implementation &#39;com.google.android.exoplayer:exoplayer-ui:2.16.1&#39;

Where I use "DefaultHttpDataSourceFactory":

    DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(
                Util.getUserAgent(context, &quot;your-application-name&quot;),
                null /* listener */,
                DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
                true /* allowCrossProtocolRedirects */
        );

Permissions:

        &lt;uses-permission tools:node=&quot;merge&quot; android:name=&quot;android.permission.INTERNET&quot; /&gt;

Application tag:

&lt;application
    .
    .
    .
    android:usesCleartextTraffic=&quot;true&quot;
    .
    .
    .&gt;

答案1

得分: 1

已删除在 2.16.0 版本中。
请使用 DefaultHttpDataSource.Factory 替代。

英文:

It was removed in 2.16.0.
Use DefaultHttpDataSource.Factory instead.

huangapple
  • 本文由 发表于 2023年2月19日 22:26:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500812.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定