Skip to content

Commit

Permalink
Setup README.md and example.
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhmdHsn313 committed May 3, 2020
1 parent f603a18 commit e8796d3
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 113 deletions.
166 changes: 156 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,160 @@
# iqplayer
# IQPlayer

Simple video player with subtitle.
Simple video player with subtitle wrote for flutter.

## Getting Started
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Muhmdhsn313/IQPlayer?style=flat-square)
![GitHub](https://img.shields.io/github/license/muhmdhsn313/iqplayer?style=flat-square)
![GitHub followers](https://img.shields.io/github/followers/muhmdhsn313?style=social)

This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
> This package as a Gift for my teacher and my leader [Mr. Muqtada Al-Sadr](https://twitter.com/Mu_AlSadr).
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
> Proudly made by [BLoC](https://pub.dev/packages/flutter_bloc).
## Features
1. [x] Play video from Assets, Files, Network by `VideoPlayerController` from video_player.
2. [ ] Parse subtitles from Assets, Files, Network `SubtitleProvider` class.
3. [ ] Custom theme you can use with `IQTheme` class.
4. [ ] Support Subtitles:
1. [ ] VTT format
2. [ ] SRT format
3. [ ] User define format
5. [x] **IQScreen:** a video player scaffold screen.
6. [ ] **IQPlayer:** a widget enable you to watch video implement with your screen.
7. [ ] **IQParser:** a subtitle package that view subtitles, included the widget and parser

# Installation
## 1. Depend on
Go to `pubspec.yaml` and set the dependencies like:

```yaml
dependencies:
iqplayer: ^0.0.1
```
Install packages from the command line with Flutter:
```shell script
flutter pub get
```

## 2. Install

### Android
Ensure the following permission is present in your Android Manifest file, located in <project root>/android/app/src/main/AndroidManifest.xml:
```xml
<uses-permission android:name="android.permission.INTERNET"/>
```
The Flutter project template adds it, so it may already be there.
### IOS

Warning: The video player is not functional on iOS simulators. An iOS device must be used during development/testing.

Add the following entry to your Info.plist file, located in <project root>/ios/Runner/Info.plist:
```plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
```
This entry allows your app to access video files by URL.


## 3. Import

Now in your Dart code, you can use:

```dart
import "package:iqplayer/iqplayer.dart";
```
# Componets
1. **IQScreen:**
```dart
IQScreen(
videoPlayerController = VideoPlayerController.network(""),
title: "Simple Video",
description: "Simple Description",
);
```
2. **IQPlayer:**

> In development.
3. **IQParser:**
> In development.
# Using

1. Start use `IQScreen` with Navigator:

```dart
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => IQScreen(
title: "",
description: "",
videoPlayerController: VideoPlayerController.network(""),
),
),
);
```

# Example
```dart
import 'package:flutter/material.dart';
import 'package:iqplayer/iqplayer.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'IQPlayer Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'IQPlayer Demo'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: RaisedButton(
child: Text('Open IQPlayer'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => IQScreen(
title: title,
description: 'Simple video as a demo video',
videoPlayerController: VideoPlayerController.network(
'https://d11b76aq44vj33.cloudfront.net/media/720/video/5def7824adbbc.mp4',
),
),
),
);
},
),
),
);
}
}
```
123 changes: 20 additions & 103 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,132 +6,49 @@ void main() {
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'IQPlayer Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: MyHomePage(title: 'IQPlayer Demo'),
);
}
}

class MyHomePage extends StatefulWidget {
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
title: Text(title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
RaisedButton(
child: Text('Go'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => IQScreen(
title: 'Demo Video',
description: 'Simple video as a demo video',
videoPlayerController: VideoPlayerController.network(
'https://d11b76aq44vj33.cloudfront.net/media/720/video/5def7824adbbc.mp4',
),
subtitleUrl:
'https://duoidi6ujfbv.cloudfront.net/media/0/subtitles/5675420c9d9a3.vtt',
),
child: RaisedButton(
child: Text('Open IQPlayer'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => IQScreen(
title: title,
description: 'Simple video as a demo video',
videoPlayerController: VideoPlayerController.network(
'https://d11b76aq44vj33.cloudfront.net/media/720/video/5def7824adbbc.mp4',
),
);
},
),
],
),
),
);
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
}

0 comments on commit e8796d3

Please sign in to comment.