mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-03 16:17:03 +00:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
commit
0d16dd0006
2 changed files with 17 additions and 24 deletions
|
@ -27,6 +27,7 @@ import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
class PackageBridge : V8Package {
|
class PackageBridge : V8Package {
|
||||||
@Transient
|
@Transient
|
||||||
|
@ -110,7 +111,7 @@ class PackageBridge : V8Package {
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeoutCounter = 0;
|
var timeoutCounter = 0;
|
||||||
var timeoutMap = HashSet<Int>();
|
var timeoutMap = ConcurrentHashMap<Int, Any?>();
|
||||||
@V8Function
|
@V8Function
|
||||||
fun setTimeout(func: V8ValueFunction, timeout: Long): Int {
|
fun setTimeout(func: V8ValueFunction, timeout: Long): Int {
|
||||||
val id = timeoutCounter++;
|
val id = timeoutCounter++;
|
||||||
|
@ -118,47 +119,39 @@ class PackageBridge : V8Package {
|
||||||
|
|
||||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||||
delay(timeout);
|
delay(timeout);
|
||||||
if(_plugin.isStopped)
|
if (_plugin.isStopped)
|
||||||
return@launch;
|
return@launch;
|
||||||
synchronized(timeoutMap) {
|
if (!timeoutMap.containsKey(id)) {
|
||||||
if(!timeoutMap.contains(id)) {
|
_plugin.busy {
|
||||||
_plugin.busy {
|
if (!_plugin.isStopped)
|
||||||
if(!_plugin.isStopped)
|
JavetResourceUtils.safeClose(funcClone);
|
||||||
JavetResourceUtils.safeClose(funcClone);
|
|
||||||
}
|
|
||||||
return@launch;
|
|
||||||
}
|
}
|
||||||
timeoutMap.remove(id);
|
return@launch;
|
||||||
}
|
}
|
||||||
|
timeoutMap.remove(id);
|
||||||
try {
|
try {
|
||||||
_plugin.busy {
|
_plugin.busy {
|
||||||
if(!_plugin.isStopped)
|
if (!_plugin.isStopped)
|
||||||
funcClone.callVoid(null, arrayOf<Any>());
|
funcClone.callVoid(null, arrayOf<Any>());
|
||||||
}
|
}
|
||||||
}
|
} catch (ex: Throwable) {
|
||||||
catch(ex: Throwable) {
|
|
||||||
Logger.e(TAG, "Failed timeout callback", ex);
|
Logger.e(TAG, "Failed timeout callback", ex);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
_plugin.busy {
|
_plugin.busy {
|
||||||
if(!_plugin.isStopped)
|
if (!_plugin.isStopped)
|
||||||
JavetResourceUtils.safeClose(funcClone);
|
JavetResourceUtils.safeClose(funcClone);
|
||||||
}
|
}
|
||||||
//_plugin.whenNotBusy {
|
//_plugin.whenNotBusy {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
synchronized(timeoutMap) {
|
timeoutMap.put(id, true);
|
||||||
timeoutMap.add(id);
|
|
||||||
}
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@V8Function
|
@V8Function
|
||||||
fun clearTimeout(id: Int) {
|
fun clearTimeout(id: Int) {
|
||||||
synchronized(timeoutMap) {
|
if (timeoutMap.containsKey(id))
|
||||||
if(timeoutMap.contains(id))
|
timeoutMap.remove(id);
|
||||||
timeoutMap.remove(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@V8Function
|
@V8Function
|
||||||
fun sleep(length: Int) {
|
fun sleep(length: Int) {
|
||||||
|
|
|
@ -580,7 +580,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
|
||||||
DefaultHttpDataSource.Factory().setUserAgent(DEFAULT_USER_AGENT);
|
DefaultHttpDataSource.Factory().setUserAgent(DEFAULT_USER_AGENT);
|
||||||
|
|
||||||
if(dataSource is JSHttpDataSource.Factory && videoSource is JSDashManifestMergingRawSource)
|
if(dataSource is JSHttpDataSource.Factory && videoSource is JSDashManifestMergingRawSource)
|
||||||
dataSource.setRequestExecutor2(videoSource.audio.getRequestExecutor());
|
dataSource.setRequestExecutor2(withContext(Dispatchers.IO){videoSource.audio.getRequestExecutor()});
|
||||||
_lastVideoMediaSource = DashMediaSource.Factory(dataSource)
|
_lastVideoMediaSource = DashMediaSource.Factory(dataSource)
|
||||||
.createMediaSource(
|
.createMediaSource(
|
||||||
DashManifestParser().parse(
|
DashManifestParser().parse(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue