我想将ExoPlayer2与播放列表一起使用,可以动态地改变音轨(在播放列表中添加或删除它们)并更改循环设置.
由于ConcatenatingMediaSource有静态数组(而不是列表),我正在实现一个DynamicMediaSource,比如连接一个但是用列表而不是数组和一个模式方法addSource来向列表添加一个以上的媒体源.
public void addSource(MediaSource mediaSource) {
this.mediaSources.add(mediaSource);
duplicateFlags = buildDuplicateFlags(this.mediaSources);
if(!mediaSources.isEmpty())
prepareSource(mediaSources.size() -1);
else
prepareSource(0);
}
Run Code Online (Sandbox Code Playgroud)
当我调用addSource时
MediaSource ms = buildMediaSource(mynewuri, null);
mediaSource.addSource(ms);
Run Code Online (Sandbox Code Playgroud)
轨道被添加到数组但似乎缺少某些东西,因为我总是在createPeriod方法中获得ArrayOutOfBoundsException.
在createPeriod中的方法
mediaSources.get(sourceIndex)...
Run Code Online (Sandbox Code Playgroud)
正在尝试访问index = mediaSources.size().
你能帮助我吗?
如何在 ExoPlayer2 上设置字幕?我试过这个 tu bild MergingMediaSource:
SingleSampleMediaSource singleSampleSource = new SingleSampleMediaSource(Uri.fromFile(new File("/sdcard/Download/a.vtt")), mediaDataSourceFactory,
Format.createTextSampleFormat(null, MimeTypes.TEXT_VTT, null, Format.NO_VALUE, C.SELECTION_FLAG_DEFAULT, "se", null, 0),
50000 //in us
);
return new MergingMediaSource(new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
mainHandler, eventLogger), singleSampleSource);
Run Code Online (Sandbox Code Playgroud)
但我收到了这个错误:
Unexpected exception loading stream
java.lang.NullPointerException: Attempt to get length of null array
at com.google.android.exoplayer2.source.SingleSampleMediaPeriod$SourceLoadable.load(SingleSampleMediaPeriod.java:272)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Run Code Online (Sandbox Code Playgroud) 抱歉这个愚蠢的问题,我正在为许多应用程序制作一个模块。
我在我的模块 ( public class CustomView extends FrameLayout) 中创建了一个自定义视图类。
我已将此模块导入应用程序,应用程序中的类可以调用我的自定义视图,但 xml 无法调用我的自定义视图 ( compile project(':mymodule'))。
我还没有找到解决方案,谢谢大家的帮助。
我PopupMenu在我的应用程序中使用了几个s,它们都按预期工作
但是我希望将白色线条分开,但我无法找到我想要设置的位置.我希望我可以访问底层的ListView,但这似乎不可能.我也看不到与分隔线相关的样式项.
这可能吗,我应该在哪里/如何设置?
customization android divider android-layout android-popupwindow
我有通过 exoplayer 播放几个音频文件的基本代码
ExtractorMediaSource audioSource = new ExtractorMediaSource(uri, dataSourceFactory, extractor, null, null);
ExtractorMediaSource audioSource2 = new ExtractorMediaSource(uri2, dataSourceFactory2, extractor, null, null);
ConcatenatingMediaSource concatenatedSource =
new ConcatenatingMediaSource(audioSource, audioSource2);
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用https://github.com/google/ExoPlayer/issues/2122中的代码示例获取所有媒体源的持续时间
Timeline timeline = mMediaPlayer.getCurrentTimeline();
int currentWindowIndex = mMediaPlayer.getCurrentWindowIndex();
long currentPosition = mMediaPlayer.getCurrentPosition();
long totalTime = 0;
Timeline.Window tmpWindow = new Timeline.Window();
if (timeline != null) {
for (int i = 0; i < timeline.getWindowCount(); i++) {
long windowDuration = timeline.getWindow(i,tmpWindow).getDurationMs();
totalTime += windowDuration;
if (i < currentWindowIndex) {
currentPosition += windowDuration; …Run Code Online (Sandbox Code Playgroud) 我有两个mpeg-ts + h.264视频文件,我试图在Android设备(Samsung Tab A 10.1")上使用ExoPlayer读取:
SimpleExoPlayerView view = new SimpleExoPlayerView(this);
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
SimpleExoPlayer mediaPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl());
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, getString(R.string.app_name)));
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource source = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
view.setPlayer(mediaPlayer);
mediaPlayer.setPlayWhenReady(true);
mediaPlayer.prepare(source);
Run Code Online (Sandbox Code Playgroud)
第一个成功(图像被正确显示)但第二个失败(没有显示图像),尽管它们在视频特性方面都非常相似.我想明白为什么.
我曾经mediainfo提取视频编码细节.
第一个视频(成功):
General
ID : 0 (0x0)
Complete name : 1080i.ts
Format : MPEG-TS
File size : 56.7 MiB
Duration : 47s 456ms
Overall …Run Code Online (Sandbox Code Playgroud) 我已经尝试学习和使用 Android Studio 大约 3 周了。我刚刚遇到了一种情况,即 AlertDialogue 在点击肯定按钮时不会关闭。
private void showGPSDisabledAlertToUser() {
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(this);
}
builder.setTitle("Turn On Location / GPS");
builder.setCancelable(false);
builder.setMessage("Application Needs To Determine Device's Physical Location.");
builder.setPositiveButton("YES, TURN ON", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); // This ain't working
goToInternetSettings();
}
});
builder.setNegativeButton("NO, CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
closeApplication();
} …Run Code Online (Sandbox Code Playgroud) 在“一次性”过滤基础数据框后,如何将变量的值分配给 ggplot 标题。
library(tidyverse)
#THIS WORKS
d <- mtcars %>%
filter(carb==4)
d %>%
ggplot()+
labs(title=paste(unique(d$carb)))+
geom_bar(aes(x=am,
fill=gear),
stat="count")
Run Code Online (Sandbox Code Playgroud)

#THIS DOESN'T WORK
mtcars %>%
filter(carb==4) %>%
ggplot()+
labs(title=paste(data=. %>% distinct(carb) %>% pull()))+
geom_bar(aes(x=am,
fill=gear),
stat="count")
#> Error in as.vector(x, "character"): cannot coerce type 'closure' to vector of type 'character'
#THIS ALSO DOESN'T WORK
mtcars %>%
filter(carb==3) %>%
ggplot()+
labs(title=paste(.$carb))+
geom_bar(aes(x=am,
fill=gear),
stat="count")
#> Error in paste(.$carb): object '.' not found
Run Code Online (Sandbox Code Playgroud)
由reprex 包(v0.3.0)于 2020 年 4 月 23 日创建
我正在尝试实现以下文章中的功能:
在鱼贝。在文章的作者使用下面的代码映射Ctrl+Z在zsh中的“FG”命令。
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
Run Code Online (Sandbox Code Playgroud)
目的是在前台和 shell 中的 vim 实例之间快速切换。
所以Ctrl+Z背景vim,然后切换到shell,然后Ctrl+Z再次应该再次前景vim,所以快速切换是可能的。
我将如何在鱼中复制它?
我正在尝试为 ExoPlayer 2 实现离线 DRM 支持,但遇到一些问题。
我找到了这段对话。ExoPlayer 1.x 有一些实现,以及如何将该实现与 ExoPlayer 2.x 一起使用的一些步骤。
我对使用OfflineDRMSessionManager哪个工具有疑问DrmSessionManager。在该示例中,DrmSessionManager 是从 ExoPlayer 1.x 导入的。如果我从 ExoPlayer 2 导入它,那么我在编译它时就会遇到问题。我的方法(open()、close()、..)有问题@Override,这些方法不在新的 DrmSessionManager 中,并且有一些新方法:acquireSession()、 ... 。