Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
flutter_plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林生雨
flutter_plugin
Commits
23f700a2
Commit
23f700a2
authored
Nov 01, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
a2d54ab0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
148 additions
and
19 deletions
+148
-19
workspace.xml
.idea/workspace.xml
+0
-0
AlbumModel.dart
example/lib/AlbumModel/page/album/AlbumModel.dart
+20
-17
GengmeiFlutterPlugin.m
ios/Classes/GengmeiFlutterPlugin.m
+24
-0
MyPlayerViewController.h
ios/Classes/MyPlayerViewController.h
+18
-0
MyPlayerViewController.m
ios/Classes/MyPlayerViewController.m
+77
-0
ScanImagePlugn.dart
lib/ScanImagePlugn.dart
+5
-2
gengmei_flutter_plugin.dart
lib/gengmei_flutter_plugin.dart
+4
-0
No files found.
.idea/workspace.xml
View file @
23f700a2
This diff is collapsed.
Click to expand it.
example/lib/AlbumModel/page/album/AlbumModel.dart
View file @
23f700a2
...
@@ -96,12 +96,11 @@ class AlbumModel {
...
@@ -96,12 +96,11 @@ class AlbumModel {
// }
// }
// });
// });
// }
// }
compute
(
paseAlbum
,
event
).
then
((
value
){
compute
(
paseAlbum
,
event
).
then
((
value
)
{
_mainValue
=
value
;
_mainValue
=
value
;
albumLive
.
notifyView
(
_mainValue
[
_nowDirName
]);
albumLive
.
notifyView
(
_mainValue
[
_nowDirName
]);
});
});
// _mainValue=newMap;
// _mainValue=newMap;
// var list = map[_nowDirName];
// var list = map[_nowDirName];
// _mainValue.forEach((k, itemList) {
// _mainValue.forEach((k, itemList) {
...
@@ -133,7 +132,6 @@ class AlbumModel {
...
@@ -133,7 +132,6 @@ class AlbumModel {
// }
// }
// }
// }
// print("EVENTTTT !! ${tempList.length} ${tempList}");
// print("EVENTTTT !! ${tempList.length} ${tempList}");
}
}
void
_onError
(
Object
error
)
{
void
_onError
(
Object
error
)
{
...
@@ -146,8 +144,7 @@ class AlbumModel {
...
@@ -146,8 +144,7 @@ class AlbumModel {
.
receiveBroadcastStream
()
.
receiveBroadcastStream
()
.
listen
(
_onEvent
,
onError:
_onError
);
.
listen
(
_onEvent
,
onError:
_onError
);
// }
// }
AlbumRepository
.
getInstance
().
scanPhoneImg
()
AlbumRepository
.
getInstance
().
scanPhoneImg
().
listen
((
value
)
{
.
listen
((
value
)
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
_mainValue
=
value
;
_mainValue
=
value
;
value
.
forEach
((
key
,
eachValue
)
{
value
.
forEach
((
key
,
eachValue
)
{
...
@@ -347,26 +344,32 @@ class AlbumModel {
...
@@ -347,26 +344,32 @@ class AlbumModel {
showPop
=
false
;
showPop
=
false
;
albumLive
.
notifyView
(
_mainValue
[
dirName
]);
albumLive
.
notifyView
(
_mainValue
[
dirName
]);
}
}
bool
previewItemClick
=
false
;
bool
previewItemClick
=
false
;
void
previewItem
(
BuildContext
context
,
int
index
,
String
pageName
)
{
void
previewItem
(
BuildContext
context
,
int
index
,
String
pageName
)
{
String
path
;
String
path
;
if
(
Platform
.
isAndroid
)
{
if
(
Platform
.
isAndroid
)
{
path
=
albumLive
.
data
[
index
].
realPath
;
path
=
albumLive
.
data
[
index
].
realPath
;
Navigator
.
push
(
context
,
CustomRoute
(
AlbumPreviewPage
(
path
,
pageName
)));
Navigator
.
push
(
context
,
CustomRoute
(
AlbumPreviewPage
(
path
,
pageName
)));
}
else
{
}
else
{
path
=
albumLive
.
data
[
index
].
path
;
if
(
albumLive
.
data
[
index
].
isVideo
)
{
GengmeiFlutterPlugin
.
playAlbumVideo
(
path
);
}
else
{
if
(
previewItemClick
)
{
return
;
}
previewItemClick
=
true
;
iosItem
(
path
,
context
,
(
value
)
{
var
realPath
=
value
[
"realImagePath"
];
Navigator
.
push
(
context
,
CustomRoute
(
AlbumPreviewPage
(
realPath
,
pageName
)));
});
}
// Navigator.push(
// Navigator.push(
// context, CustomRoute(AlbumPreviewPage(albumLive.data[index].path, pageName)));
// context, CustomRoute(AlbumPreviewPage(albumLive.data[index].path, pageName)));
if
(
previewItemClick
)
{
return
;
}
previewItemClick
=
true
;
path
=
albumLive
.
data
[
index
].
path
;
iosItem
(
path
,
context
,
(
value
)
{
var
realPath
=
value
[
"realImagePath"
];
Navigator
.
push
(
context
,
CustomRoute
(
AlbumPreviewPage
(
realPath
,
pageName
)));
});
}
}
}
}
...
@@ -375,9 +378,9 @@ class AlbumModel {
...
@@ -375,9 +378,9 @@ class AlbumModel {
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
fun
(
Map
<
String
,
String
>.
from
(
value
));
fun
(
Map
<
String
,
String
>.
from
(
value
));
}
}
previewItemClick
=
false
;
previewItemClick
=
false
;
}).
catchError
((
error
)
{
}).
catchError
((
error
)
{
previewItemClick
=
false
;
previewItemClick
=
false
;
print
(
error
);
print
(
error
);
});
});
}
}
...
...
ios/Classes/GengmeiFlutterPlugin.m
View file @
23f700a2
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
#import "Image/AlbumItem.h"
#import "Image/AlbumItem.h"
#import "ResultManager.h"
#import "ResultManager.h"
#import <ImageIO/ImageIO.h>
#import <ImageIO/ImageIO.h>
#import <AVKit/AVKit.h>
#import "MyPlayerViewController.h"
@interface
GengmeiFlutterPlugin
()
<
UIActionSheetDelegate
,
UIImagePickerControllerDelegate
,
UINavigationControllerDelegate
,
FlutterStreamHandler
>
//一定要声明这三个协议,缺一不可
@interface
GengmeiFlutterPlugin
()
<
UIActionSheetDelegate
,
UIImagePickerControllerDelegate
,
UINavigationControllerDelegate
,
FlutterStreamHandler
>
//一定要声明这三个协议,缺一不可
//@property(nonatomic)FlutterResult result;
//@property(nonatomic)FlutterResult result;
...
@@ -408,6 +410,28 @@ NSString *cacheDirectory;
...
@@ -408,6 +410,28 @@ NSString *cacheDirectory;
}
else
{
}
else
{
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
nil
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
nil
];
}
}
}
else
if
([
@"play_album_video"
isEqualToString
:
call
.
method
]
){
long
resultTemp
=
self
.
resultKey
;
NSString
*
path
=
call
.
arguments
;
if
([[
self
.
scanMap
allKeys
]
containsObject
:
path
]){
PHAsset
*
assets
=
self
.
scanMap
[
path
];
MyPlayerViewController
*
video
=
[[
MyPlayerViewController
alloc
]
init
];
[
viewController
presentViewController
:
video
animated
:
YES
completion
:
nil
];
// video.player= [[AVPlayeralloc]initWithURL:url];
[
video
playMovie
:
assets
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
@YES
];
// PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
// options.version = PHImageRequestOptionsVersionCurrent;
// options.networkAccessAllowed = true;
// options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
// [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
// AVURLAsset *urlAsset = (AVURLAsset *)asset;
// AVPlayerViewController* video=[[AVPlayerViewController alloc] init];
// [viewController presentViewController:video animated:YES completion:nil];
// [video playMovie:urlAsset.URL];
// [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES];
// }];
}
}
else
{
}
else
{
result
(
FlutterMethodNotImplemented
);
result
(
FlutterMethodNotImplemented
);
}
}
...
...
ios/Classes/MyPlayerViewController.h
0 → 100644
View file @
23f700a2
//
// AVPlayerViewController.h
// Pods
//
// Created by Apple on 2019/11/1.
//
#ifndef AVPlayerViewController_h
#define AVPlayerViewController_h
#endif
/* AVPlayerViewController_h */
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>
@interface
MyPlayerViewController
:
UIViewController
-
(
void
)
playMovie
:(
PHAsset
*
)
assets
;
@end
ios/Classes/MyPlayerViewController.m
0 → 100644
View file @
23f700a2
//
// AVPlayerViewController.m
// gengmei_flutter_plugin
//
// Created by Apple on 2019/11/1.
//
#import <Foundation/Foundation.h>
#import "MyPlayerViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>
@interface
MyPlayerViewController
()
@property
(
nonatomic
)
dispatch_queue_t
queue
;;
@end
@implementation
MyPlayerViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
queue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_SERIAL
);
// UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// button.frame = CGRectMake(100, 100, 100, 100);
// [button setTitle:@"TICK" forState:UIControlStateNormal];
// button.backgroundColor = [UIColor brownColor];
// [button addTarget:self action:@selector(playMovie) forControlEvents:UIControlEventTouchUpInside];
// [self.view addSubview:button];
}
-
(
void
)
playMovie
:
(
PHAsset
*
)
assets
{
dispatch_async
(
self
.
queue
,
^
{
PHVideoRequestOptions
*
options
=
[[
PHVideoRequestOptions
alloc
]
init
];
// options.version = PHImageRequestOptionsVersionCurrent;
options
.
networkAccessAllowed
=
true
;
// options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
[[
PHImageManager
defaultManager
]
requestAVAssetForVideo
:
assets
options
:
options
resultHandler
:^
(
AVAsset
*
_Nullable
asset
,
AVAudioMix
*
_Nullable
audioMix
,
NSDictionary
*
_Nullable
info
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
AVURLAsset
*
urlAsset
=
(
AVURLAsset
*
)
asset
;
// AVPlayerViewController* video=[[AVPlayerViewController alloc] init];
// [viewController presentViewController:video animated:YES completion:nil];
// [video playMovie:urlAsset.URL];
AVPlayer
*
player
=
[
AVPlayer
playerWithURL
:
urlAsset
.
URL
];
// 2.创建视频播放视图的控制器
AVPlayerViewController
*
playerVC
=
[[
AVPlayerViewController
alloc
]
init
];
playerVC
.
player
=
player
;
playerVC
.
entersFullScreenWhenPlaybackBegins
=
YES
;
playerVC
.
exitsFullScreenWhenPlaybackEnds
=
YES
;
playerVC
.
videoGravity
=
AVLayerVideoGravityResizeAspect
;
playerVC
.
view
.
center
=
self
.
view
.
center
;
playerVC
.
view
.
frame
=
self
.
view
.
bounds
;
playerVC
.
showsPlaybackControls
=
YES
;
playerVC
.
view
.
translatesAutoresizingMaskIntoConstraints
=
YES
;
// 隐藏 控制控件
// playerVC.showsPlaybackControls = NO;
// [self presentViewController:playerVC animated:YES completion:nil];
// 自定义位置
// playerVC.view.frame = CGRectMake(200, 300, 300, 300);
[
self
.
view
addSubview
:
playerVC
.
view
];
[
self
addChildViewController
:
playerVC
];
// if (playerVC.readyForDisplay) {
[
playerVC
.
player
play
];
// }
});
}];
});
// 1.AVPlayer
}
@end
lib/ScanImagePlugn.dart
View file @
23f700a2
...
@@ -47,10 +47,13 @@ class ScanImagePlugn {
...
@@ -47,10 +47,13 @@ class ScanImagePlugn {
return
await
channel
.
invokeMethod
(
"IOS_IMAGE_BY_PATH"
,
path
);
return
await
channel
.
invokeMethod
(
"IOS_IMAGE_BY_PATH"
,
path
);
}
}
static
Future
<
Map
>
ios_album_item
(
static
Future
<
Map
>
ios_album_item
(
MethodChannel
channel
,
String
path
)
async
{
MethodChannel
channel
,
String
path
)
async
{
return
await
channel
.
invokeMethod
(
"IOS_IMAGE_ITEM"
,
path
);
return
await
channel
.
invokeMethod
(
"IOS_IMAGE_ITEM"
,
path
);
}
}
static
Future
<
bool
>
playAlbumVideo
(
MethodChannel
channel
,
String
path
)
async
{
return
await
channel
.
invokeMethod
(
"play_album_video"
,
path
);
}
}
}
class
ScanImageItem
{
class
ScanImageItem
{
...
...
lib/gengmei_flutter_plugin.dart
View file @
23f700a2
...
@@ -31,6 +31,10 @@ class GengmeiFlutterPlugin {
...
@@ -31,6 +31,10 @@ class GengmeiFlutterPlugin {
return
await
ScanImagePlugn
.
ios_album_item
(
_channel
,
path
);
return
await
ScanImagePlugn
.
ios_album_item
(
_channel
,
path
);
}
}
static
Future
<
bool
>
playAlbumVideo
(
String
path
)
async
{
return
await
ScanImagePlugn
.
playAlbumVideo
(
_channel
,
path
);
}
static
Future
<
bool
>
quitPage
()
async
{
static
Future
<
bool
>
quitPage
()
async
{
return
await
ScanImagePlugn
.
quitPage
(
_channel
);
return
await
ScanImagePlugn
.
quitPage
(
_channel
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment