Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ A VLC-powered alternative to Flutter's video_player that supports iOS and Androi

## Installation

### Version 3.0 Upgrade For Existing Apps
For migration to version 3, the project is based in swift. Your existing project will need to migratate

Delete existing ios folder from root of flutter project.
Run this command flutter create -i swift .

This command will create only ios directory with swift support. See https://stackoverflow.com/questions/52244346/how-to-enable-swift-support-for-existing-project-in-flutter

Change your project to use 9.0
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'


### iOS
For iOS, you need to opt into the Flutter embedded views preview.
This is done by adding the following to your project's `<project root>/ios/Runner/Info.plist` file (see example for details):
Expand Down
32 changes: 32 additions & 0 deletions example/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
**/*sync/
.sconsign.dblite
.tags*
**/.vagrant/
**/DerivedData/
Icon?
**/Pods/
**/.symlinks/
profile
xcuserdata
**/.generated/
Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
1 change: 1 addition & 0 deletions example/ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9a6723ad18e3f950fccdc81adda11616
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def parse_KV_file(file, separator='=')
end

target 'Runner' do
use_frameworks!
use_modular_headers!

# Flutter Pod

copied_flutter_dir = File.join(__dir__, 'Flutter')
Expand Down Expand Up @@ -75,9 +78,6 @@ target 'Runner' do
end
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
Expand Down
291 changes: 80 additions & 211 deletions example/ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,8 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -36,8 +38,8 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -59,6 +61,8 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Latest</string>
<key>PreviewsEnabled</key>
<false/>
</dict>
Expand Down
6 changes: 0 additions & 6 deletions example/ios/Runner/AppDelegate.h

This file was deleted.

13 changes: 0 additions & 13 deletions example/ios/Runner/AppDelegate.m

This file was deleted.

13 changes: 13 additions & 0 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -26,6 +26,13 @@
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand All @@ -41,7 +48,5 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>
1 change: 1 addition & 0 deletions example/ios/Runner/Runner-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import "GeneratedPluginRegistrant.h"
9 changes: 0 additions & 9 deletions example/ios/Runner/main.m

This file was deleted.

24 changes: 24 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class MyAppScaffoldState extends State<MyAppScaffold> {

VlcPlayerController _videoViewController;
VlcPlayerController _videoViewController2;
bool isPlaying = true;

@override
void initState() {
Expand Down Expand Up @@ -93,6 +94,12 @@ class MyAppScaffoldState extends State<MyAppScaffold> {
),
),
),
FlatButton(
child: isPlaying ? Icon(Icons.pause) : Icon(Icons.play_arrow) ,
onPressed: () => {
playOrPauseVideo()
}
),
FlatButton(
child: Text("Change URL"),
onPressed: () => _videoViewController.setStreamUrl(
Expand Down Expand Up @@ -126,6 +133,23 @@ class MyAppScaffoldState extends State<MyAppScaffold> {
);
}

void playOrPauseVideo() {
String state = _videoViewController.playingState.toString();

if ( state == "PlayingState.PLAYING" ){
_videoViewController.pause();
setState(() {
isPlaying = false;
});
} else {
_videoViewController.play();
setState(() {
isPlaying = true;
});
}

}

void _createCameraImage() async {
Uint8List file = await _videoViewController.takeSnapshot();
setState(() {
Expand Down
27 changes: 27 additions & 0 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_vlc_player_example/main.dart';

void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data.startsWith('Running on:'),
),
findsOneWidget,
);
});
}
1 change: 1 addition & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ Icon?
.tags*

/Flutter/Generated.xcconfig
/Flutter/flutter_export_environment.sh
30 changes: 0 additions & 30 deletions ios/Classes/FlutterVlcPlayerPlugin.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
#import <Flutter/Flutter.h>
#import <MobileVLCKit/MobileVLCKit.h>

@interface FlutterVlcPlayerPlugin : NSObject<FlutterPlugin>
@end

@interface FLTPlayerView : NSObject<FlutterPlatformView>

/// View to show video over
@property (nonatomic, strong) UIView *hostedView;
/// Player showing video
@property (nonatomic, strong) VLCMediaPlayer *player;
/// result to comunicate back to Flutter
@property (nonatomic) FlutterResult result;
/// Set to indicate that aspect has been set which is only needed once.
@property (nonatomic, assign) BOOL aspectSet;


/// Initialize a new instance with the channel
/// @param methodChannel Method channel for communication from flutter
/// @param eventChannel Event channel for communication back to flutter
+ (instancetype)initWithChannels: (FlutterMethodChannel*) methodChannel andEventChannel:(FlutterEventChannel*) eventChannel;

@end

@interface FLTPlayerViewFactory : NSObject<FlutterPlatformViewFactory>
+ (instancetype)initWithRegistrar : (NSObject<FlutterPluginRegistrar>*)registrar;
@end

@interface FLTPlayerEventStreamHandler : NSObject<FlutterStreamHandler, VLCMediaPlayerDelegate>

@property (nonatomic) FlutterEventSink eventSink;

@end
Loading