Skip to content

Commit

Permalink
Audio api, source param, and refresh button fix (stream-labs#909)
Browse files Browse the repository at this point in the history
* add source param

* remove refresh from prod apps

* audio API
  • Loading branch information
avacreeth authored Oct 12, 2018
1 parent fc103b6 commit 688131b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/components/pages/PlatformAppContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Pop Out
</button>
<button
v-if="isUnpacked"
@click="refreshApp"
class="button button--default">
Reload
Expand Down
18 changes: 18 additions & 0 deletions app/services/platform-apps/api/modules/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Inject } from 'util/injector';
import { Subject } from 'rxjs/Subject';
import { PlatformAppsService } from 'services/platform-apps';
import { ScenesService } from 'services/scenes';
import { AudioService } from 'services/audio';

interface ISourceFlags {
audio: boolean;
Expand All @@ -23,6 +24,8 @@ interface ISource {
flags: ISourceFlags;
size: ISourceSize;
appId?: string;
muted?: boolean;
volume?: number;
}

export class SourcesModule extends Module {
Expand All @@ -33,6 +36,7 @@ export class SourcesModule extends Module {
@Inject() private sourcesService: SourcesService;
@Inject() private platformAppsService: PlatformAppsService;
@Inject() private scenesService: ScenesService;
@Inject() private audioService: AudioService;

constructor() {
super();
Expand Down Expand Up @@ -152,6 +156,14 @@ export class SourcesModule extends Module {
const source = this.sourcesService.getSource(patch.id);

if (patch.name) source.setName(patch.name);

if (patch.muted != null) {
this.audioService.getSource(patch.id).setMuted(patch.muted);
}

if (patch.volume != null) {
this.audioService.getSource(patch.id).setDeflection(patch.volume);
}
}

@apiMethod()
Expand Down Expand Up @@ -198,6 +210,12 @@ export class SourcesModule extends Module {
serialized.appId = source.getPropertiesManagerSettings().appId;
}

if (source.audio) {
const audioSource = this.audioService.getSource(source.sourceId);
serialized.volume = audioSource.fader.deflection;
serialized.muted = audioSource.muted;
}

return serialized;
}

Expand Down
12 changes: 10 additions & 2 deletions app/services/platform-apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,21 @@ export class PlatformAppsService extends
return !!page.persistent;
}

getPageUrlForSource(appId: string, appSourceId: string) {
getPageUrlForSource(appId: string, appSourceId: string, settings = '') {
const app = this.getApp(appId);

if (!app) return null;

const source = app.manifest.sources.find(source => source.id === appSourceId);
return this.getPageUrl(appId, source.file);
let url = this.getPageUrl(appId, source.file);

if (settings) {
url = `${url}&settings=${encodeURIComponent(settings)}`;
}

url = `${url}&source=true`;

return url;
}

getPageUrl(appId: string, page: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class PlatformAppManager extends PropertiesManager {
}

updateUrl() {
let url = this.platformAppsService.getPageUrlForSource(
const url = this.platformAppsService.getPageUrlForSource(
this.settings.appId,
this.settings.appSourceId
);
Expand All @@ -73,11 +73,6 @@ export class PlatformAppManager extends PropertiesManager {
return;
}

// Append app settings to URL
if (this.settings.appSettings) {
url = `${url}&settings=${encodeURIComponent(this.settings.appSettings)}`
}

if (this.obsSource.settings['url'] !== url) {
this.obsSource.update({ url });
}
Expand Down

0 comments on commit 688131b

Please sign in to comment.