lishuhao / flutter_video_player

A Flutter plugin for integrating qiniu video player in iOS and Android applications.
Other
6 stars 2 forks source link

IOS的代码 #1

Open jendy2012 opened 5 years ago

jendy2012 commented 5 years ago

import "PlPlayerPlugin.h"

import <AVFoundation/AVFoundation.h>

import <PLPlayerKit/PLPlayer.h>

@class PLControlView;

int64_t FLTCMTimeToMillis(CMTime time) { return time.value * 1000 / time.timescale; }

@interface FLTFrameUpdater : NSObject @property(nonatomic) int64_t textureId; @property(nonatomic, readonly) NSObject* registry;

@implementation FLTFrameUpdater

@end

static void timeRangeContext = &timeRangeContext; static void statusContext = &statusContext; static void playbackLikelyToKeepUpContext = &playbackLikelyToKeepUpContext; static void playbackBufferEmptyContext = &playbackBufferEmptyContext; static void* playbackBufferFullContext = &playbackBufferFullContext;

@interface FLTVideoPlayer : NSObject<FlutterTexture, FlutterStreamHandler> @property(readonly, nonatomic) PLPlayer player; @property (nonatomic, strong) UIButton playButton; @property (nonatomic, strong) UIImageView thumbImageView; @property (nonatomic, strong) UIButton closeButton; @property (nonatomic, strong) NSURL url; @property (nonatomic, strong) UIImage thumbImage; @property (nonatomic, strong) NSURL thumbImageURL; //是否启用手指滑动调节音量和亮度, default YES @property (nonatomic, assign) BOOL enableGesture; @property (nonatomic, strong) UIView topBarView; @property (nonatomic, strong) UILabel titleLabel; @property (nonatomic, strong) UIButton moreButton; @property (nonatomic, strong) UIButton *exitfullScreenButton;

@property (nonatomic, strong) UIView bottomBarView; @property (nonatomic, strong) UISlider slider; @property (nonatomic, strong) UILabel playTimeLabel; @property (nonatomic, strong) UILabel durationLabel; @property (nonatomic, strong) UIProgressView bufferingView; @property (nonatomic, strong) UIButton enterFullScreenButton;

// 在bottomBarView上面的播放暂停按钮,全屏的时候,显示 @property (nonatomic, strong) UIButton *pauseButton;

@property (nonatomic, assign) UIDeviceOrientation deviceOrientation;

@property (nonatomic, strong) PLPlayerOption *playerOption; @property (nonatomic, assign) BOOL isNeedSetupPlayer;

@property (nonatomic, strong) NSTimer *playTimer;

// 在屏幕中间的播放和暂停按钮,全屏的时候,隐藏 @property (nonatomic, strong) UIButton centerPlayButton; @property (nonatomic, strong) UIButton centerPauseButton;

@property (nonatomic, strong) UIButton *snapshotButton;

@property (nonatomic, strong) UIPanGestureRecognizer panGesture; @property (nonatomic, strong) UITapGestureRecognizer tapGesture;

@property (nonatomic, strong) PLControlView *controlView;

// 很多时候调用stop之后,播放器可能还会返回请他状态,导致逻辑混乱,记录一下,只要调用了播放器的 stop 方法,就将 isStop 置为 YES 做标记 @property (nonatomic, assign) BOOL isStop;

// 当底部的 bottomBarView 因隐藏的时候,提供两个 progrssview 在最底部,随时能看到播放进度和缓冲进度 @property (nonatomic, strong) UIProgressView bottomPlayProgreeeView; @property (nonatomic, strong) UIProgressView bottomBufferingProgressView;

// 适配iPhone X @property (nonatomic, assign) CGFloat edgeSpace;

@property(readonly, nonatomic) CADisplayLink displayLink; @property(nonatomic) FlutterEventChannel eventChannel; @property(nonatomic) FlutterEventSink eventSink; @property(nonatomic, readonly) bool disposed; @property(nonatomic, readonly) bool isPlaying; @property(nonatomic, readonly) bool isLooping; @property(nonatomic, readonly) bool isInitialized;

@implementation FLTVideoPlayer

define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

// [self.playButton hide]; // [_player.playerView showFullLoading]; // [self.view bringSubviewToFront:self.closeButton]; }

pragma mark - PLPlayerDelegate

@end

// AppDelegate实现 @interface PlPlayerPlugin () @property(readonly, nonatomic) NSObject registry; @property(readonly, nonatomic) NSObject messenger; @property(readonly, nonatomic) NSMutableDictionary players; //创建词典对象 @property(readonly, nonatomic) NSObject registrar; @end

// Registrar 声明和实现 @implementation PlPlayerPlugin

@end

jendy2012 commented 5 years ago

测试可以播放。但是需要整合一下。

lishuhao commented 5 years ago

@jendy2012

Thank you for your contribution, I will add it when I have time.