Commit 1e5bf7a3 authored by hark's avatar hark
Browse files

gitmodules

parent 5a646a61
#!/usr/bin/env python3
import gtk
import gst
pipe = 'audiotestsrc is-live=true volume=0.1 '
def gstmessage_cb(bus, message, pipe):
if message.type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
pipe.set_state(gst.STATE_NULL)
pipeline = 'espeak text="Hello, World!" ! autoaudiosink'
pipe = gst.parse_launch(pipeline)
bus = pipe.get_bus()
bus.add_signal_watch()
bus.connect('message', gstmessage_cb, pipe)
pipe.set_state(gst.STATE_PLAYING)
gtk.main()
"""Example shows how to listen to events."""
import asyncio
import logging
import sys
from obswsrc import OBSWS
from obswsrc.logs import logger
# We will output logging to sys.stdout, as many events might raise errors
# on creation (that's because protocol.json is not perfect) - such errors
# are logged by obs-ws-rc automatically, we just need to see them
logger.setLevel(logging.ERROR)
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
async def main():
async with OBSWS('localhost', 4444, "password") as obsws:
print("Connection established.")
# We will receive events here by awaiting for them (you can await for
# an event of a specific type by providing `type_name` argument to
# the obsws.event() method)
event = await obsws.event()
# Awaited event might be None if connection is closed
while event is not None:
print("Awaited for '{}' event!".format(event.type_name))
event = await obsws.event()
print("Connection terminated.")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import logging
logging.basicConfig(level=logging.INFO)
sys.path.append('../')
from obswebsocket import obsws, requests
host = "localhost"
port = 4444
password = "secret"
ws = obsws(host, port, password)
ws.connect()
try:
scenes = ws.call(requests.GetSceneList())
for s in scenes.getScenes():
name = s['name']
print("Switching to {}".format(name))
ws.call(requests.SetCurrentScene(name))
time.sleep(2)
print("End of list")
except KeyboardInterrupt:
pass
ws.disconnect()
"""Example shows how to send requests and get responses."""
import asyncio
import pprint
from obswsrc import OBSWS
from obswsrc.requests import ResponseStatus, StartStreamingRequest
from obswsrc.types import Stream, StreamSettings
pp = pprint.PrettyPrinter(indent=4)
async def main():
async with OBSWS('localhost', 4444, "password") as obsws:
# We can send an empty StartStreaming request (in that case the plugin
# will use OBS configuration), but let's provide some settings as well
stream_settings = StreamSettings(
server="rtmp://hlsorigindev.laglab.org/stream",
key="teststream",
use_auth=False
)
stream = Stream(
settings=stream_settings,
type="rtmp_custom",
)
# Now let's actually perform a request
response = await obsws.require(StartStreamingRequest(stream=stream))
pp.pprint(response)
# Check if everything is OK
if response.status == ResponseStatus.OK:
print("Streaming has started")
else:
print("Couldn't start the stream! Reason:", response.error)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment