SplitmediaLabsLimited / xjs

XSplit JS Framework. Make plugins for XSplit Broadcaster, quickly and easily.
Other
39 stars 11 forks source link

getPlaybackDuration only works for active scene #326

Open BrendaH opened 3 years ago

BrendaH commented 3 years ago

I needed to loop over all sources in my project and store the duration (if it was a video), but it turned out that getPlaybackDuration only works for media in the currently active scene. For media in other scenes it returns 0.

My workaround is to directly use xjs.IO.getVideoDuration(await item.getValue()) / 1e7 to get the duration in seconds.

I think either getPlaybackDurationshould just work for all media items that you use it on, or the documentation should list this limitation.

SML-MeSo commented 3 years ago

I'm afraid that is indeed a limitation. Will check with the team on how to properly communicate this in the documentation as this is not the only method exhibiting that behavior. Almost all source-specific calls fail when called while the source is not loaded, i.e. when not in active AND not kept loaded in memory.

I guess this was overlooked since there was a time (1.x days I think), when all properties and method are not accessible if called when source is not kept loaded or not in the active scene. Until core changes were made to enable access to item-specific calls for unloaded items, that is.