getLivePreview method Null safety
- {int frames = 5,
- dynamic frameDelay = 34,
- required StreamController controller}
override
initiate connection to camera and get the stream this is different for Z1/V and SC2
Implementation
static void getLivePreview(
{int frames = 5,
frameDelay = 34,
required StreamController controller}) async {
// Future<void> getLivePreview({int frames = 5, int frameDelay = 67}) async {
Map<String, String> header = {
'Content-Type': 'application/json; charset=utf-8',
'X-XSRF-Protected': '1',
'Accept': 'multipart/x-mixed-replace'
};
Map<String, dynamic> body = {'name': 'camera.getLivePreview'};
Uri url = Uri.parse('http://192.168.1.1/osc/commands/execute');
var request = http.Request('POST', url);
request.body = jsonEncode(body);
client.head(url, headers: header);
if (!keepRunning) {
client.close();
client = http.Client();
http.StreamedResponse response = await client.send(request);
Stream dataStream = response.stream;
keepRunning = true;
getFrames(
dataStream: dataStream,
frames: frames,
frameDelay: frameDelay,
controller: controller);
}
}