Live Preview with Flutter

The place to discuss development topics.
Discussions on the RICOH THETA API and SDK, image processing of spherical images, other hardware related topics, introduction of useful libraries, etc.

Live Preview with Flutter

Postby David93505285 » 12 Aug 2019, 13:30

Hi! I am trying to build an app that connects to the Ricoh SC camera with flutter. So far, I am able to do basic things like setting the API to v2 or to take pictures. However, i have trouble to obtain the data from the live stream in my app. I am new to flutter and dart and therefore unexperienced with streams and futures.
This is code where I want to obtain the live preview stream:

Code: Select all
void startLivePreview() {

    Future<http.Response> response = _getLivePreview();

    Stream<http.Response> responseStream = response.asStream();

    responseStream.listen((onData) {
      print('\n\nStatuscode stream: ${onData.statusCode}\n\n');
      print('\n\nReceived some data\n\n');
    }, onDone: () {
      print("\n\nStream Done\n\n");
    }, onError: (error) {
      print("\n\nStreaming Error\n\n");
    }).onError((handleError) {
      throw handleError;

static const String postExecute = '/osc/commands/execute';
String jsonGetLivePreview = json.encode({'name': 'camera.getLivePreview', 'parameters': {}});

Future<http.Response> _getLivePreview() =>
      fetchPost(postExecute, jsonGetLivePreview);

Future<http.Response> fetchPost(
      String postCommand, String jsonRequest) async {
    var uri = new Uri.http(_ipAddress, postCommand);

    final response = await, body: jsonRequest);

    if (response.statusCode == 200) {
      print('\nStatuscode: ${response.statusCode}\n\n');
      print('\nResponse: ${response.body}\n\n');
      return response;
    } else {
      print('Statuscode: ${response.statusCode}');
      throw Exception('Failed to load post');

Sometimes I get statuscode 403, sometimes no response at all.
Anybody willing to help me out or show me a working flutter example?
Posts: 1
Joined: 12 Aug 2019, 13:22

Return to Development

All times are UTC