Пример #1
0
        public async Task SetSourceDimensions(string sceneName, string sourceName, StreamingSourceDimensions dimensions)
        {
            StreamlabsOBSSceneItem sceneItem = await this.GetSceneItem(sceneName, sourceName);

            if (sceneItem != null)
            {
                StreamlabsOBSRequest request = new StreamlabsOBSRequest("setTransform", sceneItem.ResourceID);

                JObject positionJObj = new JObject();
                positionJObj["x"] = dimensions.X;
                positionJObj["y"] = dimensions.Y;

                JObject scaleObj = new JObject();
                scaleObj["x"] = dimensions.XScale;
                scaleObj["y"] = dimensions.YScale;

                JObject jobj = new JObject();
                jobj["position"] = positionJObj;
                jobj["scale"]    = scaleObj;
                jobj["rotation"] = dimensions.Rotation;

                request.Arguments.Add(jobj);
                await this.SendAndReceive(request);
            }
        }
Пример #2
0
        public async Task SetSourceVisibility(string sceneName, string sourceName, bool visibility)
        {
            StreamlabsOBSSceneItem sceneItem = await this.GetSceneItem(sceneName, sourceName);

            if (sceneItem != null)
            {
                StreamlabsOBSRequest request = new StreamlabsOBSRequest("setVisibility", sceneItem.ResourceID);
                request.Arguments.Add(visibility);
                await this.SendAndReceive(request);
            }
        }
Пример #3
0
        public async Task <StreamingSourceDimensions> GetSourceDimensions(string sceneName, string sourceName)
        {
            StreamlabsOBSSceneItem sceneItem = await this.GetSceneItem(sceneName, sourceName);

            if (sceneItem != null)
            {
                return(new StreamingSourceDimensions()
                {
                    X = (int)sceneItem.Transform.Position.X,
                    Y = (int)sceneItem.Transform.Position.Y,
                    XScale = (int)sceneItem.Transform.Scale.X,
                    YScale = (int)sceneItem.Transform.Scale.X,
                    Rotation = (int)sceneItem.Transform.Rotation
                });
            }
            return(null);
        }
Пример #4
0
        public async Task SetWebBrowserSourceURL(string sceneName, string sourceName, string url)
        {
            StreamlabsOBSSceneItem sceneItem = await this.GetSceneItem(sceneName, sourceName);

            if (sceneItem != null)
            {
                StreamlabsOBSRequest getSourceRequest = new StreamlabsOBSRequest("getSource", sceneItem.ResourceID);
                getSourceRequest.Arguments.Add(sceneItem.SourceID);
                StreamlabsOBSSource source = await this.GetResult <StreamlabsOBSSource>(getSourceRequest);

                if (source != null && source.Type.Equals("browser_source"))
                {
                    IEnumerable <JObject> properties = await this.GetArrayResult <JObject>(new StreamlabsOBSRequest("getPropertiesFormData", source.ResourceID));

                    if (properties != null)
                    {
                        foreach (JObject property in properties)
                        {
                            if (property["name"] != null && property["name"].ToString().Equals("url"))
                            {
                                property["value"] = url;
                            }
                        }

                        StreamlabsOBSRequest setSourcePropertiesRequest = new StreamlabsOBSRequest("setPropertiesFormData", source.ResourceID);
                        JArray array = new JArray();
                        foreach (JObject property in properties)
                        {
                            array.Add(property);
                        }
                        setSourcePropertiesRequest.Arguments.Add(array);
                        await this.SendAndReceive(setSourcePropertiesRequest);
                    }
                }
            }
        }