tizen_api 1.0.4 copy "tizen_api: ^1.0.4" to clipboard
tizen_api: ^1.0.4 copied to clipboard

Control your Samsung Tizen TV, writen in pure dart native. Trying the example project is highly encouraged :)

tizen #

TV Remote for all mobile devices

How to use #

  1. First call initialize in your main function
TizenHelperMethods.initialize();
  1. You can search devices like this
Future<void> scanNetwork() async {
    await (NetworkInfo().getWifiIP()).then(
      (ip) async {
        final String subnet = ip!.substring(0, ip.lastIndexOf('.'));
        const port = 8002;
        for (var i = 0; i < 256; i++) {
          String ip = '$subnet.$i';
          await Socket.connect(ip, port,
                  timeout: const Duration(milliseconds: 50))
              .then((socket) async {
            await InternetAddress(socket.address.address)
                .reverse()
                .then((value) {
              addDeviceToList(socket.address.address);
            }).catchError((error) {
              addDeviceToList(socket.address.address);
            });
            socket.destroy();
          }).catchError((error) => null);
        }
      },
    );
    print('Done');
}

void addDeviceToList(String ip) async {
    final response = await Dio().get("http://$ip:8001/api/v2/");
    print("Found $ip");
    TV tv = TV.fromJson(response.data as Map<String, dynamic>);
    setState(() {
        tvs.add(tv);
    });
}
  1. Before calling tv methods please set it like so
TizenHelperMethods.selectedTv = tvVar;
  1. Control the TV using
TizenHelperMethods.selectedTv!.connectToSocket(preferences.getString("token"));

TizenHelperMethods.selectedTv!.addToSocket(KeyCodes.KEY_VOLDOWN);
// TizenHelperMethods.selectedTv!.addToSocket(KeyCodes.KEY_VOLUP);
// TizenHelperMethods.selectedTv!.addToSocket(KeyCodes.KEY_POWER);

Test the example app #

The example is TV remote app and is very fun to test.

You should to try it up with your TV.

Thanks #

Thanks @shaharhn for developing the base of this package

4
likes
0
points
50
downloads

Publisher

unverified uploader

Weekly Downloads

Control your Samsung Tizen TV, writen in pure dart native. Trying the example project is highly encouraged :)

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, network_info_plus, web_socket_channel

More

Packages that depend on tizen_api