Update flutter/http.dart to use dart:io. (#5940)

This commit is contained in:
Chinmay Garde
2016-09-20 14:17:33 -07:00
committed by GitHub
parent 4f0eff31bc
commit 400585cb96
25 changed files with 1697 additions and 479 deletions

View File

@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/http.dart' as http;
import 'package:mojo/core.dart' as core;
// All of these sounds are marked as public domain at soundbible.
const String chimes = "http://soundbible.com/grab.php?id=2030&type=wav";
@@ -42,7 +43,10 @@ class PianoKey {
Future<Null> load(mojom.MediaServiceProxy mediaService) async {
try {
mediaService.createPlayer(player);
player.prepare(await http.readDataPipe(soundUrl), (bool ignored) { });
http.Response response = await http.get(soundUrl);
core.MojoDataPipe pipe = new core.MojoDataPipe();
core.DataPipeFiller.fillHandle(pipe.producer, response.bodyBytes.buffer.asByteData());
player.prepare(pipe.consumer, (bool ignored) { });
} catch (e) {
print("Error: failed to load sound file $soundUrl");
player.close();