Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
507e6bfd
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
大约 1 年 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
507e6bfd
编写于
12月 18, 2018
作者:
T
toss156
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加沙盒浏览器音视频文件预览支持
上级
f9a87d20
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
12 deletion
+41
-12
DoraemonKit/Src/Core/Plugin/Sanbox/VC/DoraemonSanboxDetailViewController.m
...ore/Plugin/Sanbox/VC/DoraemonSanboxDetailViewController.m
+41
-12
未找到文件。
DoraemonKit/Src/Core/Plugin/Sanbox/VC/DoraemonSanboxDetailViewController.m
浏览文件 @
507e6bfd
...
...
@@ -5,6 +5,8 @@
// Created by yixiang on 2018/6/20.
//
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>
#import "DoraemonSanboxDetailViewController.h"
#import "DoraemonToastUtil.h"
#import "UIView+Doraemon.h"
...
...
@@ -14,6 +16,7 @@
@property
(
nonatomic
,
strong
)
UIImageView
*
imageView
;
@property
(
nonatomic
,
strong
)
UITextView
*
textView
;
@property
(
nonatomic
,
strong
)
AVPlayerViewController
*
playerView
;
@end
...
...
@@ -23,25 +26,35 @@
[
super
viewDidLoad
];
self
.
title
=
DoraemonLocalizedString
(
@"文件预览"
);
if
(
self
.
filePath
.
length
>
0
){
if
(
self
.
filePath
.
length
>
0
)
{
NSString
*
path
=
self
.
filePath
;
if
(
[
path
hasSuffix
:
@".png"
]
||
[
path
hasSuffix
:
@".PNG"
]
if
([
path
hasSuffix
:
@".png"
]
||
[
path
hasSuffix
:
@".PNG"
]
||
[
path
hasSuffix
:
@".jpg"
]
||
[
path
hasSuffix
:
@".JPG"
]
||
[
path
hasSuffix
:
@".jpeg"
]
||
[
path
hasSuffix
:
@".JPEG"
]
||
[
path
hasSuffix
:
@".gif"
]
||
[
path
hasSuffix
:
@".GIF"
]
){
||
[
path
hasSuffix
:
@".gif"
]
||
[
path
hasSuffix
:
@".GIF"
])
{
// 图片文件
UIImage
*
img
=
[[
UIImage
alloc
]
initWithContentsOfFile
:
self
.
filePath
];
[
self
setOriginalImage
:
img
];
}
else
if
(
[
path
hasSuffix
:
@".strings"
]
||
[
path
hasSuffix
:
@".plist"
]
||
[
path
hasSuffix
:
@".txt"
]
||
[
path
hasSuffix
:
@".log"
]
||
[
path
hasSuffix
:
@".csv"
]
){
}
else
if
([
path
hasSuffix
:
@".strings"
]
||
[
path
hasSuffix
:
@".plist"
]
||
[
path
hasSuffix
:
@".txt"
]
||
[
path
hasSuffix
:
@".log"
]
||
[
path
hasSuffix
:
@".csv"
])
{
// 文本文件
if
(
[
path
hasSuffix
:
@".plist"
]
||
[
path
hasSuffix
:
@".strings"
]
){
[
self
setContent
:[[
NSDictionary
dictionaryWithContentsOfFile
:
path
]
description
]];
}
else
{
}
else
{
NSData
*
data
=
[
NSData
dataWithContentsOfFile
:
path
];
[
self
setContent
:[[
NSString
alloc
]
initWithData
:
data
encoding
:
NSUTF8StringEncoding
]];
}
}
else
{
}
else
if
([
path
hasSuffix
:
@".mp4"
]
||
[
path
hasSuffix
:
@".MP4"
]
||
[
path
hasSuffix
:
@".mov"
]
||
[
path
hasSuffix
:
@".MOV"
]
||
[
path
hasSuffix
:
@".mp3"
]
||
[
path
hasSuffix
:
@".MP3"
])
{
// 音视频文件
[
self
setMediaFile
:
self
.
filePath
];
}
else
{
// 其他文件
NSString
*
str
=
[
NSString
stringWithFormat
:
@"Not support %@ file!"
,
[
path
pathExtension
]];
[
self
setContent
:
str
];
}
...
...
@@ -50,7 +63,7 @@
}
}
-
(
void
)
setContent
:(
NSString
*
)
text
{
-
(
void
)
setContent
:(
NSString
*
)
text
{
_textView
=
[[
UITextView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
_textView
.
font
=
[
UIFont
systemFontOfSize
:
12
.
0
f
];
_textView
.
textColor
=
[
UIColor
blackColor
];
...
...
@@ -65,7 +78,7 @@
[
self
.
view
addSubview
:
_textView
];
}
-
(
void
)
setOriginalImage
:(
UIImage
*
)
originalImage
{
-
(
void
)
setOriginalImage
:(
UIImage
*
)
originalImage
{
CGFloat
viewWidth
=
self
.
view
.
doraemon_width
;
CGFloat
viewHeight
=
self
.
view
.
doraemon_height
;
CGFloat
imageWidth
=
originalImage
.
size
.
width
;
...
...
@@ -80,7 +93,7 @@
scaledImageWidth
=
imageWidth
/
imageScale
;
x
=
(
viewWidth
-
scaledImageWidth
)
/
2
;
y
=
0
;
}
else
{
//图片横屏分量比较大
}
else
{
//图片横屏分量比较大
imageScale
=
imageWidth
/
viewWidth
;
scaledImageWidth
=
viewWidth
;
scaledImageHeight
=
imageHeight
/
imageScale
;
...
...
@@ -93,5 +106,21 @@
[
self
.
view
addSubview
:
_imageView
];
}
-
(
void
)
setMediaFile
:(
NSString
*
)
mediaFile
{
_playerView
=
[[
AVPlayerViewController
alloc
]
init
];
NSURL
*
sourceMediaURL
=
[
NSURL
fileURLWithPath
:
mediaFile
];
AVAsset
*
mediaAsset
=
[
AVURLAsset
URLAssetWithURL
:
sourceMediaURL
options
:
nil
];
AVPlayerItem
*
playerItem
=
[
AVPlayerItem
playerItemWithAsset
:
mediaAsset
];
AVPlayer
*
player
=
[
AVPlayer
playerWithPlayerItem
:
playerItem
];
self
.
playerView
.
player
=
player
;
self
.
playerView
.
view
.
translatesAutoresizingMaskIntoConstraints
=
YES
;
self
.
playerView
.
showsPlaybackControls
=
YES
;
self
.
playerView
.
view
.
bounds
=
self
.
view
.
bounds
;
[
self
.
playerView
.
player
play
];
[
self
addChildViewController
:
self
.
playerView
];
[
self
.
view
addSubview
:
self
.
playerView
.
view
];
}
@end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录