cdnbye 0.1.0 copy "cdnbye: ^0.1.0" to clipboard
cdnbye: ^0.1.0 copied to clipboard

discontinuedreplaced by: flutter_p2p_engine
outdated

A new flutter plugin project.

example/lib/main.dart

import 'package:cdnbye_example/pages/customVideoPage.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:cdnbye/cdnbye.dart';
import 'package:video_player/video_player.dart';
import 'package:chewie/chewie.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: CustomVideoPlayerPage(),
    );
  }
}

class VideoPlayerWidget extends StatefulWidget {
  @override
  _VideoPlayerWidgetState createState() => _VideoPlayerWidgetState();
}

class _VideoPlayerWidgetState extends State<VideoPlayerWidget> {
  VideoPlayerController _controller;
  bool _isPlaying = false;
  String url = 'http://www.w3school.com.cn/example/html5/mov_bbb.mp4';

  ChewieController chewieController;
  @override
  void initState() {
    super.initState();

    _controller = VideoPlayerController.network(url);
    chewieController = ChewieController(
      videoPlayerController: _controller,
      aspectRatio: 4.0 / 3.0,
      autoPlay: false,
      looping: true,
    );
  }

  @override
  Widget build(BuildContext context) {
    Widget video = Container(
      height: 300,
      child: Center(
        child: Chewie(
          controller: chewieController,
        ),
      ),
    );
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        appBar: AppBar(
          title: Text('视频播放'),
        ),
        body: ListView(
          children: <Widget>[
            video,
            Container(
              height: 200,
              child: Center(
                child: RaisedButton(
                  child: Text('init'),
                  onPressed: () async {
                    await Cdnbye.init('free');
                  },
                ),
              ),
            ),
            Container(),
            Container(
              height: 200,
              child: Center(
                child: RaisedButton(
                  child: Text('free'),
                  onPressed: () async {
                    var newUrl = await Cdnbye.parseStreamURL('url://asdfghjk');
                    print('转换后的URL:$newUrl');
                  },
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
20
likes
0
points
57
downloads

Publisher

verified publishercdnbye.com

Weekly Downloads

A new flutter plugin project.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on cdnbye