gpt4 book ai didi

java - com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException : Response code: 404

转载 作者:行者123 更新时间:2023-12-04 13:00:13 43 4
gpt4 key购买 nike

好的,所以我要播放 YouTube video通过 ExoPlayer 通过使用 Javascript 接口(interface)调用播放程序...

问题是,当我尝试使用 ExoPlayer 打开视频时,它确实尝试打开链接而不是没有播放,当我看到 Logcat 时,我得到了错误

E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:300)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65)
at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:156)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)

我尝试将 final 添加到包含视频 URL 的字符串中,就像 here 中的答案所建议的那样,但仍然得到相同的错误

所以,我尝试向上滚动 Logcat,发现 SSL 错误
SSL_connect:error exit in 3RSH_A SSLv3 read server hello A

然后我尝试使用 this 中的解决方案但仍然有同样的错误

我的代码

ExoPlayer.java

public class ExoPlayer extends AppCompatActivity{
private PlayerView playerView;
private SimpleExoPlayer simpleExoPlayer;
public static String url;
public Context context;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);

final String video = getIntent().getStringExtra("video");

iniExoPlayer(video);
}


public void iniExoPlayer(String url){
Log.d("owo",url);
simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this);
playerView = findViewById(R.id.video_player);
playerView.setPlayer(simpleExoPlayer);

//#Default Data Source use this
DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(this, "app-name"));
MediaSource videoSource = new SsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url));
simpleExoPlayer.prepare(videoSource);
simpleExoPlayer.setPlayWhenReady(true);
}

network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<base includeSubdomains="true">MainUrl</base>
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>

</network-security-config>

这是我的 Logcat

最佳答案

检查您的 URL 链接。因为该链接上没有视频
我通过更改 URL 解决了

关于java - com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException : Response code: 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59084676/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com