Beispiel #1
0
    def update(self):
        global globSettings

        self.selection['menu'].delete(0, 'end')
        for choice in self.scenes:
            self.selection['menu'].add_command(label=choice,
                                               command=tk._setit(
                                                   self.scene, choice))
        stored = obs.obs_data_get_string(globSettings, "scene")
        if stored in self.scenes:
            self.scene.set(stored)
        else:
            self.scene.set(self.scenes[0])

        self.list.delete(0, self.list.index('end'))

        self.duration.set(obs.obs_data_get_int(globSettings, "duration"))

        templates = obs.obs_data_get_array(globSettings,
                                           "templates" + self.scene.get())
        if templates == None:
            template = obs.obs_data_array_create()
            obs.obs_data_set_array(globSettings,
                                   "templates" + self.scene.get(), template)
        length = obs.obs_data_array_count(templates)
        for i in range(length):
            item = obs.obs_data_array_item(templates, i)
            self.list.insert(
                'end',
                obs.obs_data_get_string(item, "id") + ". " +
                obs.obs_data_get_string(item, "name"))
            obs.obs_data_release(item)

        obs.obs_data_array_release(templates)
def update_match_video():
    global last_video_path

    print('update_match_video')

    # TODO: actually set the video starting at the start of the game, rather
    # than the slot. Also involves ensuring that our timings are in step with
    # the compbox.

    path = video_path.get()
    if last_video_path == path:
        print(f"{path!r} has already played")
        return

    # TODO: can we pull the current video from the source? I tried this but
    # couldn't work out how.
    last_video_path = path
    print(f"Updating to {path!r}")

    source = obs.obs_get_source_by_name(source_name)
    if source != None:
        print('got source')

        settings = obs.obs_data_create()
        source_id = obs.obs_source_get_id(source)
        if source_id == "ffmpeg_source":

            obs.obs_data_set_string(settings, "local_file", path)
            obs.obs_data_set_bool(settings, "is_local_file", True)

            # updating will automatically cause the source to
            # refresh if the source is currently active
            obs.obs_source_update(source, settings)

            # TODO: this ends up resetting the size of the video within OBS. Can
            # we inspect the source beforehand and preserve the apparent size?
            # Might be moot if all our videos are the same size and we're
            # showing them at 100% scale, but would be good to sort properly.

        elif source_id == "vlc_source":
            # "playlist"
            array = obs.obs_data_array_create()
            item = obs.obs_data_create()
            obs.obs_data_set_string(item, "value", path)
            obs.obs_data_array_push_back(array, item)
            obs.obs_data_set_array(settings, "playlist", array)

            # updating will automatically cause the source to
            # refresh if the source is currently active
            obs.obs_source_update(source, settings)
            obs.obs_data_release(item)
            obs.obs_data_array_release(array)

        obs.obs_data_release(settings)
        obs.obs_source_release(source)

    print('update_match_video done')
Beispiel #3
0
def _make_list(arr, obj):
    d = _obs.obs_data_array_create()
    try:
        for o in obj:
            d2 = _obs.obs_data_create()
            try:
                set_data(d2, o.items())
                _obs.obs_data_array_push_back(arr, d2)
            finally:
                _obs.obs_data_release(d2)
        d_, d = d, None
        return d_
    finally:
        if d:
            _obs.obs_data_release(d)
def change_input():
    global globSettings
    url = obs.obs_data_get_string(globSettings, "url")
    source = obs.obs_data_get_string(globSettings, "source")
    qual = obs.obs_data_get_string(globSettings, "res")
    if url != None and source != None:
        sourceObj = obs.obs_get_source_by_name(source)
        try:
            streamUrl = ""
            stream = streamlink.streams(url)

            if qual in stream:
                streamUrl = stream[qual].url
            elif qual + "60" in stream:
                streamUrl = stream[qual + "60"].url
            elif qual + "_alt" in stream:
                streamUrl = stream[qual + "_alt"].url
            elif qual + "60_alt" in stream:
                streamUrl = stream[qual + "60_alt"].url
            elif "best" in stream:
                streamUrl = stream["best"].url

            if streamUrl != "" and sourceObj != None:
                source_id = obs.obs_source_get_id(sourceObj)
                settings = obs.obs_data_create()
                if source_id == "ffmpeg_source":
                    obs.obs_data_set_string(settings, "input", streamUrl)
                    obs.obs_data_set_bool(settings, "is_local_file", False)
                    obs.obs_source_update(sourceObj, settings)
                else:
                    array = obs.obs_data_array_create()
                    data = obs.obs_data_create()
                    obs.obs_data_set_string(data, "name", streamUrl)
                    obs.obs_data_set_string(data, "value", streamUrl)
                    obs.obs_data_array_push_back(array, data)
                    obs.obs_data_release(data)
                    obs.obs_data_set_array(settings, "playlist", array)
                    obs.obs_source_update(sourceObj, settings)
                    obs.obs_data_array_release(array)

                obs.obs_data_release(settings)
        except streamlink.StreamlinkError:
            pass
        obs.obs_source_release(sourceObj)
Beispiel #5
0
 def add(self):
     global globSettings
     loc = filedialog.askopenfilename(filetypes=[("JSON", "*.json")],
                                      title="Open Template File")
     templates = obs.obs_data_get_array(globSettings,
                                        "templates" + self.scene.get())
     if templates == None:
         template = obs.obs_data_array_create()
         obs.obs_data_set_array(globSettings,
                                "templates" + self.scene.get(), template)
     new = obs.obs_data_create()
     length = obs.obs_data_array_count(templates) + 1
     obs.obs_data_set_string(new, "id", str(length))
     obs.obs_data_set_string(new, "name", os.path.basename(loc))
     obs.obs_data_set_string(new, "loc", loc)
     obs.obs_data_array_push_back(templates, new)
     obs.obs_data_release(new)
     obs.obs_data_array_release(templates)
     self.list.insert('end', str(length) + ". " + os.path.basename(loc))