Skip to content

Commit

Permalink
Merge pull request #370 from jobsofferings/feature_close_video
Browse files Browse the repository at this point in the history
Fix an issue where tracks keeps on after the camera app is closed
  • Loading branch information
User782Tec authored Jan 23, 2024
2 parents 9da50e1 + f485403 commit e17d4fa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,21 @@ function closenotice() {
$('#notice-back').removeClass('show');
}, 200);
}

function closeVideo() {
var video = apps.camera.video
if (video) {
try {
var stream = video.srcObject;
var tracks = stream.getTracks();
tracks.forEach(function (track) {
track.stop();
});
video.srcObject = null;
} catch (error) {}
}
}

var shutdown_task = []; //关机任务,储存在这个数组里
// 为什么要数组?
// 运行的指令
Expand Down Expand Up @@ -3126,6 +3141,10 @@ function hidewin(name, arg = 'window') {
$('.window.' + name).removeClass('notrans');
$('.window.' + name).removeClass('max');
$('.window.' + name).removeClass('show');
if (name == 'camera') {
// 相机关闭后统一清理 tracks
closeVideo()
}
if (arg == 'window') {
$('#taskbar').attr('count', Number($('#taskbar').attr('count')) - 1)
$('#taskbar>.' + name).remove();
Expand Down

0 comments on commit e17d4fa

Please sign in to comment.