SplitmediaLabsLimited / xui-old

1 stars 1 forks source link

programmatically update item values of certain plugin types #3

Closed dabruhce closed 9 years ago

dabruhce commented 9 years ago

I looked at this a bit and could not determine if it was possible in the current xui api code. Is it possible to update item values as well.

For example if a user wanted to update rmtp item value url and stream name to a new value?

Or add a new title (legacy) item?

ghost commented 9 years ago

Hi, you could modify the item value using setValue method of each item object. It's best that you first fetch the current item value using getValue and then modify the value. getValue would most certainly return a string when used on an RTMP Stream item.

Here's an example string returned by an RTMP Stream's getValue:

C:\Users\UserThingy\AppData\Local\SplitMediaLabs\XSplit\email@email.com\SwfPlugins2.0\LiveStream.swf*<config><params rtmp="rtmp://asdfasdf.com" stream="tester" smoothing="true" buffer="1"/></config>

You'll notice the rtmp attribute, that would be your rtmp url, while the stream attribute is your stream name. Modify that, and then send back the string to the item object using the setValue method.

I made an example gist for your reference: https://gist.github.com/dcefram/e46e2e381ebd2489553a

dabruhce commented 9 years ago

I took a look at the gist and while I can update the values of the rtmp stream, it appears to change from rtmp to another local media type after the update. You can click media source and change to a local file type, but the remote rmtp url definition seems to be gone.

Maybe Im missing an update Ill look at this more tomorrow and update.

ghost commented 9 years ago

Sorry, I forgot to mention that the expected string that would be passed to setValue should be a decoded string (decodeURIComponent).

I updated the example gist, and that should get it to work. Please do test it out :)

dabruhce commented 9 years ago

Issue persists.

Before the code executes rtmp values are like this... rtmpdefault

after they are like this... rtmp_after_set

I forked your gist and removed the updates to the stream & name. So it enters the setValue with the same value it entered with and setsValue with decodeURIComponent. Same issue

https://gist.github.com/tkntobfrk/45daf803e2010cae9fc1

essentially this...

}).then(function(itemString) {

            rtmpItem.setValue(decodeURIComponent(itemString));
        });
ghost commented 9 years ago

Thanks for trying this out. We're working on the next version of our framework, so I just got time to debug this today. We found out that this is bug on this version of xui framework with regards with the fetching of the value using getValue method. This is due to the initial assumption that a non-json string should throw an error which would cause getValue to return the actual string rather than parsing it to an XML object. It turns out that JSON.parse does not throw an error when trying to parse the prop:item value of an rtmp stream source item, which is a bug on the framework side.

I updated the gist for the workaround, by using the internal.Item.get/internal.Item.set method. I tested it on my side and it works :) (https://gist.github.com/dcefram/e46e2e381ebd2489553a)

This issue was already addressed, but that framework version is still yet to be released/announced. We'll inform you when it's already out :D

dabruhce commented 9 years ago

Cheer thanks so much. This works perfectly. I was afraid I might need to do some lame autoit/ahk workaround, as an added bonus it autoplays the clip on init.

ghost commented 9 years ago

Cool! Happy to know that it works :)

I'll be closing this issue then. You could open another issue if you got other questions or concerns, we'll do our best to answer it :D