我试图在视频的每一帧上绘制一个位图作为叠加.我找到了一个关于如何解码和编码视频的例子,它正在发挥作用.这个例子有一个TextureRenderer类,它有一个drawFrame我需要修改的函数才能添加位图.我是opengl的新手,但我了解到我需要用位图创建一个纹理并绑定它.我在下面的代码中尝试过,但它抛出异常.
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS …Run Code Online (Sandbox Code Playgroud) 我有一个LazyColumn嵌套的LazyRows(类似于 Netflix 或 Spotify 主页提要)。简而言之,我遇到的问题是,当页面内容更改时,嵌套 LazyRows 的滚动位置不会重置。
例如,用户向下滚动主页,滚动第三个水平部分看到第五项,刷新主页,加载新的页面内容。但第三个水平部分仍然显示第五个而不是重置到初始位置。
在代码方面,这里有一些片段:
在主屏幕可组合项中:
Scaffold {
when (val viewState = viewModel.stateFlow.collectAsState().value) {
is ViewState.Success -> {
Box {
with(viewState.data) {
LazyColumn {
itemsIndexed(sections) { index, section ->
LazyRow{}
//etc.
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 HomeViewModel 中,当用户刷新主屏幕时,调用此函数:
private val _stateFlow = MutableStateFlow<ViewState<HomePage>>(ViewState.Loading)
val stateFlow: StateFlow<ViewState<HomePage>>
get() = _stateFlow
fun loadHomeScreen() {
viewModelScope.launch {
repository.getHomePage()
.collect {
_stateFlow.tryEmit(it)
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我已成功添加额外的代码,以便在用户刷新主屏幕时将主页的 LazyColumn 滚动到屏幕顶部。但是,我仍然不知道对于嵌套 LazyRows 来说最好的方法是什么。我不想保留对他们的引用,LazyListState因为该解决方案无法很好地扩展。但是,我很困惑为什么在发出新状态并显示新的 LazyRows 时滚动位置没有被重置。这是 Compose …
android kotlin android-jetpack-compose lazycolumn compose-recomposition
我signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)在我的应用程序中随机获得Native Crash .App循环遍历文件并在C++代码中分析它们并返回一个浮点数组.这是在AsyncTask中完成的,它在处理文件时运行一段时间.我在导致崩溃的代码中做错了什么?或者它是一个超级能源问题?谢谢.
这是AsyncTask doInBackground函数:
protected String doInBackground(Object... urls) {
for (int i = 0; i < songFiles.size(); i++) {
SongFile temp = songFiles.get(i);
try {
float[] f = Analyser.getInfo(temp.getPath());
if (f != null && f.length > 1) {
...save to DB
}
}
} catch (Exception e) {
}
}
return "";
}
Run Code Online (Sandbox Code Playgroud)
Java和C++代码之间的功能:
extern "C" JNIEXPORT jfloatArray Java_com_superpowered_SuperpoweredPlayer_getInfo(JNIEnv *env, jobject instance,jstring filepath) {
jfloatArray ret;
char *Path= (char *) env->GetStringUTFChars(filepath, JNI_FALSE); …Run Code Online (Sandbox Code Playgroud) 我有一个媒体代理,从网址下载mp4视频并将其转发到连接的流.我遇到的问题是它从视频中下载了几个字节,然后它抛出java.net.SocketException: sendto failed: EBADF (Bad file descriptor)并停止(你可以看到下面的日志).我用几个mp4链接进行了测试.我读到该问题可能是由于连接关闭,但正如您在日志中看到的那样,连接是"保持活动".我知道这可能是服务器问题,但我想确保客户端正确地执行所有操作.
private void processRequestOld(Socket client) throws IllegalStateException, IOException {
HttpResponse realResponse = download(uri);
if (realResponse == null) {
return;
}
InputStream data = realResponse.getEntity().getContent();
StatusLine line = realResponse.getStatusLine();
HttpResponse response = new BasicHttpResponse(line);
response.setHeaders(realResponse.getAllHeaders());
StringBuilder httpString = new StringBuilder();
httpString.append(response.getStatusLine().toString());
httpString.append("\n");
for (Header h : response.getAllHeaders()) {
Log.d("Headers: ", h.getName() + " " + (h.getValue()));
httpString.append(h.getName()).append(": ").append(h.getValue()).append(
"\n");
}
httpString.append("\n");
try {
byte[] buffer = httpString.toString().getBytes();
int readBytes;
client.getOutputStream().write(buffer, 0, buffer.length);
byte[] …Run Code Online (Sandbox Code Playgroud) 该应用程序基于Grafika的相机捕获活动(https://github.com/google/grafika/tree/master/src/com/android/grafika)。用户点击按钮以录制视频。Nexus 5x随机崩溃。下面发布了2条日志,分别说明何时可以正常工作以及什么时候不工作。请告诉我造成此崩溃的原因是什么,以及是否需要我发布代码的任何部分。
工作方式:
11-21 15:55:22.301 26556-27085/com.testvideo I/OMXClient: MuxOMX ctor
11-21 15:55:22.505 26556-27085/com.testvideo E/ACodec: [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -1010
11-21 15:55:22.505 26556-27085/com.testvideo W/ACodec: do not know color format 0x7fa30c04 = 2141391876
11-21 15:55:22.506 26556-27085/com.testvideo W/ACodec: do not know color format 0x7f000789 = 2130708361
11-21 15:55:22.518 26556-27085/com.testvideo I/ACodec: setupAVCEncoderParameters with [profile: Baseline] [level: Level31]
11-21 15:55:22.520 26556-27085/com.testvideo I/ACodec: [OMX.qcom.video.encoder.avc] cannot encode color aspects. Ignoring.
11-21 15:55:22.520 26556-27085/com.testvideo I/ACodec: [OMX.qcom.video.encoder.avc] cannot encode HDR static metadata. Ignoring.
11-21 15:55:22.520 26556-27085/com.testvideo …Run Code Online (Sandbox Code Playgroud) 我正在尝试向其他媒体应用公开媒体项目,这些应用可以通过我的MediaBrowserServiceCompat服务浏览我的应用内容。在我的onLoadChildren方法中,我正在构建 MediaBrowserCompat.MediaItem一个MediaDescriptionCompat包含Bundle一些我需要播放该项目的额外内容的 。
public class Service extends MediaBrowserServiceCompat {
...
@Override
public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result) {
val bundle = Bundle().apply {
putString("extra", "some value")
}
MediaDescriptionCompat description = new MediaDescriptionCompat.Builder()
.setMediaId(mediaId)
.setExtras(bundle)
.setTitle("title")
.setSubtitle("subtitle")
.setIconUri(uri)
.build();
MediaBrowserCompat.MediaItem item = new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE);
val items = ArrayList<MediaBrowserCompat.MediaItem>()
items.add(item)
result.sendResult(items)
}
Run Code Online (Sandbox Code Playgroud)
因此,在onPlayFromMediaId(String mediaId, Bundle extras)用户单击该项目时收到的回调中,我得到了正确的结果,mediaId但这extras是一个空包。
private class MediaSessionCallback extends MediaSessionCompat.Callback {
...
@Override …Run Code Online (Sandbox Code Playgroud) 最近开始因为java.lang.SecurityException: Binder invocation to an incorrect interface我们的应用程序崩溃,这只发生在6.0和6.0.1操作系统上.堆栈跟踪从崩溃报告服务中提取,无法在任何Android 6设备上本地复制.
该应用程序使用一个"服务"调用'startForeground',堆栈跟踪似乎指向该方法调用.
java.lang.SecurityException: Binder invocation to an incorrect interface
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.app.ActivityManagerProxy.setServiceForeground(ActivityManagerNative.java:4487)
at android.app.Service.startForeground(Service.java:652)
at com.anghami.audio.MusicService.J(MusicService.java:3517)
at com.anghami.audio.MusicService.b(MusicService.java:2676)
at com.anghami.audio.MusicService.F(MusicService.java:2647)
at com.anghami.audio.MusicService.a(MusicService.java:2421)
at com.anghami.audio.MusicService_.a(MusicService_.java:21)
at com.anghami.audio.MusicService_$4.a(MusicService_.java:214)
at org.androidannotations.api.a$a.run(BackgroundExecutor.java:401)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
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)
Run Code Online (Sandbox Code Playgroud) android ×7
java ×4
bitmap ×1
c++ ×1
grafika ×1
kotlin ×1
lazycolumn ×1
mediabrowser ×1
mediacodec ×1
networking ×1
proxy ×1
superpowered ×1