obs_websocket_dart 0.0.2 copy "obs_websocket_dart: ^0.0.2" to clipboard
obs_websocket_dart: ^0.0.2 copied to clipboard

A package that gives you an easy-to-use API to connect to OBS using the obs-websocket plugin.

obs_websocket_dart #

I needed a way to connect to OBS (Open Broadcast Software) that was easy to use and allowed me to fully control it. Endded up using this repository as a base to make my own package.

This dart package allow you to connect to OBS using the obs-websocket plugin.

Getting Started #

In your flutter project pubspec.yaml add the dependency:

dependencies:
  ...
  obs_websocket_dart: ^0.0.2

Example #

Import the library, create the object, set the data and call the connect function. Be shure to have the obs-websocket plugin installed in your OBS instance.

Connection with password:

import 'package:obs_websocket_dart/obs_websocket_dart.dart';

ObsWebsocket obs = new ObsWebsocket();
obs.setAddress('127.0.0.1');
obs.setPort('4444');
obs.setPassword('*****');
await obs.connect();

Connection without password:

import 'package:obs_websocket_dart/obs_websocket_dart.dart';

ObsWebsocket obs = new ObsWebsocket();
obs.setAddress('127.0.0.1');
obs.setPort('4444');
await obs.connect();

Sending Commands #

The commands can be found on the protocol page of the obs-websocket github page.

obs.send('GetCurrentScene');

obs.send('SetPreviewScene', {"scene-name": "newScene"});

This function returns a Future, so in case of commands that are expeced to return some information can be used this way

obs.send('GetPreviewScene').then(event) {
    for (dynamic scene in event['scenes']) {
        print('SCENE ' + scene['name']);
        for (dynamic source in scene['sources']) {
            print('SOURCE ' + source['name']);
        }
    }
});

Listening to Events #

The events can be found on the protocol page of the obs-websocket github page.

This function returns a stream. This is one of the ways to use streams in dart.

obs.event('StreamStatus').listen((event) {
    print('StreamStatus: ' + event['stream-timecode'].toString() + ' at ' + event['kbits-per-sec'].toString() + 'Kb/s');
});
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A package that gives you an easy-to-use API to connect to OBS using the obs-websocket plugin.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

crypto, flutter, web_socket_channel

More

Packages that depend on obs_websocket_dart