当前位置:网站首页>Tiktok practice ~ upload and release app video
Tiktok practice ~ upload and release app video
2022-06-24 23:36:00 【gblfy】

List of articles
One 、API read
1. Select or capture video
find uni.chooseVideo(OBJECT)API,
Select or capture a video file :https://uniapp.dcloud.net.cn/api/media/video.html#choosevideo
2. Cloud functions API~ Upload files
Use of api:uniCloud.uploadFile(Object uploadFileOptions)
uniCloud API file

3. Video cut frame
purpose : Video frame cut as video cover
Alibaba cloud service for video frame cutting 
Video framing service
Alibaba cloud video frames 
Two 、App End video upload process
2.1. Upload flowchart

2.2. Process brief
- 1. Verify user login status , Not logged in , Then jump to the login page to log in , The login process continues .
- 2. Click the middle release button
- 3. Select or capture video , Click on the confirmation
- 4. Jump to the short video publishing page with the file information
- 5. When the short video publishing page is loaded , Receive video file information , Parsing file information
- 6. Configuration file path and cloud file name
- 7. Call cloud function , Perform short video cloud upload
- 8. Short video uploading process , The progress bar is dynamically displayed according to the actual upload progress
- 9. Short video upload completed , Call alicloud video framing service , Make video frame cut cover
- 10. Short video message encapsulation
- 11. Supplement the uploaded content
- 12. Post a short video , Call the back-end interface service
- 13. Short video file information , Brief treatment , Execute stock drop processing
3、 ... and 、 Front end source code practice
3.1. choice / Take a short video
// Listen for the click event of the middle button
uni.onTabBarMidButtonTap(()=>{
// Cannot publish video without logging in
var myUserInfo = getApp().getUserInfoSession();
if (myUserInfo == null) {
uni.showToast({
duration: 3000,
title: " Please log in ~",
icon: "none"
});
uni.navigateTo({
url: "../loginRegist/loginRegist",
animationType: "slide-in-bottom",
success() {
me.loginWords = " Please log in "
}
});
return;
}
// console.log('onTabBarMidButtonTap');
uni.switchTab({
url: "../me/me"
});
uni.chooseVideo({
sourceType: ['album'],
success(e) {
uni.navigateTo({
url: "/pages/publish/publish?fileObjectEvent=" + JSON.stringify(e)
})
/** * Or use uniCloud, Finish uploading on the client , Reduce links , Because the file is large , The communication link and time consumption are doubled */
var times = new Date().getTime();
}
})
});
3.2. Short video upload
// Triggered when the current page is loaded
onLoad(params) {
var me = this;
this.statusBarHeight = system.statusBarHeight;
this.screenWidth = system.screenWidth;
// File event object passed from the previous page , It contains the video content selected from the album
var fileObjectEvent = JSON.parse(params.fileObjectEvent);
var times = new Date().getTime();
uniCloud.uploadFile({
// File object to upload -> Get temporary video path
filePath: fileObjectEvent.tempFilePath,
// When using alicloud ,cloudPath Is the cloud file name
// Customize according to specific business
cloudPath: times + '.mp4',
// Progress bar Events
onUploadProgress(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
// This value is the percentage of dynamic change during video uploading , To show the specific progress of uploading
me.percentCompleted = percentCompleted;
},
// Process operation after uploading
success(f) {
// Get the video path
var videoUrlTemp = f.filePath;
// Get video ID
var videoUrl = f.fileID;
// Get video parameters
me.tempFilePath = videoUrlTemp;
me.videoUrl = videoUrl;
me.tempCover = videoUrl + "?x-oss-process=video/snapshot,t_1,f_jpg,ar_auto"; // Cut frame
me.width = fileObjectEvent.width;
me.height = fileObjectEvent.height;
}
});
},
3.3. Progress bar page
<!-- Progress bar -->
<view style="marginTop:60rpx;display: flex;flex-direction: column;justify-content: center;"
v-if="percentCompleted != 100">
<progress :percent="percentCompleted" stroke-width="3" activeColor="#ef274d" backgroundColor="#F1F1F1"
:style="{screenWidth: screenWidth + 'px'}" />
<text style="color: #F1F1F1;font-size: 16px;text-align: center;margin-top: 20px;"
:style="{screenWidth: screenWidth + 'px'}"> Video uploading ~ Please be patient ~~</text>
<image mode="aspectFit" src="../../static/images/loading-4.gif"
style="width: 600rpx;height: 600rpx;align-self: center;">
</view>
3.4. Add short video content
<textarea class="vlog-content" placeholder-style="color: #9798a0;" placeholder=" Add appropriate title content " :value="title"
:model="title" maxlength="60" @input="typingContent" confirm-type="done"></textarea>
3.5. Video release
<view :class="{'btn-publish':!publichTouched, 'btn-publish-touched': publichTouched}"
style="margin-top: 30rpx;height: 90rpx;display: flex;justify-content: center;border-radius: 20px;"
@touchstart="touchstartPublich" @touchend="touchendPublich" @click="doPublich">
<text style="color: #e6e6e6;font-size: 18px;align-self: center;font-weight: 500;"> Release Vlog</text>
</view>
doPublich() {
var me = this;
var userId = getApp().getUserInfoSession().id;
var vlog = {
"vlogerId": userId,
"url": me.videoUrl,
"cover": me.tempCover,
"title": me.title,
"width": me.width,
"height": me.height
};
// Release video
var serverUrl = app.globalData.serverUrl;
uni.request({
method: "POST",
header: {
headerUserId: userId,
headerUserToken: app.getUserSessionToken()
},
url: serverUrl + "/vlog/publish",
data: vlog,
success(result) {
if (result.data.status == 200) {
uni.showToast({
title: " Successful release !",
icon: "none"
})
uni.navigateBack({
delta: 1,
animationType: 'zoom-fade-in',
animationDuration: 1000
});
uni.switchTab({
url: "../me/me"
})
} else {
uni.showToast({
title: result.data.msg,
icon: "none",
duration: 3000
});
}
}
});
},
3.6. Video preview
preview() {
uni.navigateTo({
url: "/pages/publish/preview?videoUrl=" + this.videoUrl + "&width=" + this.width + "&height=" +
this.height,
animationType: 'slide-in-bottom',
animationDuration: 500
})
},
Four 、 Back end source code practice
4.1. Short video release
/** * Release vlog video * * @param vlogBO * @return */
@PostMapping("publish")
public GraceJSONResult publish(@RequestBody VlogBO vlogBO) {
vlogService.createVlog(vlogBO);
return GraceJSONResult.ok();
}
4.2. Logical processing
/** * Release vlog video * * @param vlogBO */
@Transactional
@Override
public void createVlog(VlogBO vlogBO) {
// video ID
String vid = sid.nextShort();
Vlog vlog = new Vlog();
BeanUtils.copyProperties(vlogBO, vlog);
vlog.setId(vid);
vlog.setLikeCounts(0);
vlog.setCommentsCounts(0);
vlog.setIsPrivate(YesOrNo.NO.type);
vlog.setCreatedTime(new Date());
vlog.setUpdatedTime(new Date());
vlogMapper.insert(vlog);
}
5、 ... and 、 Appreciation of renderings
5.1.


边栏推荐
- Why is it that the "Zhongtai" that was originally eaten by civil engineering is no longer fragrant?
- 基于三维GIS开发的水电工程建设方案
- R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、自定义FUN参数为多个统计量函数名称的列表计算多个统计量
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the AIC function to compare the AIC values of the two models (simpl
- [JS] - [tree] - learning notes
- 抖音实战~发布短视频流程梳理
- throttle-debounce. JS: a small anti shake throttling function library
- Solution of IP network broadcasting system in Middle School Campus - Design Guide for Campus Digital IP broadcasting system
- R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、使用summary函数获取模型汇总统计信息、解读模型系数交互作用及其显著性
- 376. 机器任务
猜你喜欢
Unveiling the secrets of the Winter Olympics | smartbi's partners supported the "front and back" of the Beijing Winter Olympics

企业数据防泄露解决方案分享

今天睡眠质量记录79分

QT display RGB data
![[JS] - [array application] - learning notes](/img/8a/808fde0cc86e0ec5e1f5558ba196b4.png)
[JS] - [array application] - learning notes

第六章 网络学习相关技巧5(超参数验证)

Mirror image of sword finger offer binary tree

Volcano成Spark默认batch调度器

File contains vulnerability issues

First person singular reading notes
随机推荐
Tomorrow is the PMP Exam (June 25). Have you understood all this?
去商场逛街
Mirror image of sword finger offer binary tree
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、对匹配后的样本的不同分组对应的目标变量的均值进行Welch双样本t检验分析、双独立样本t检验
国内有哪些好的智能家居品牌支持homekit?
No main manifest attribute in jar
#22Map介绍与API
2021-2022中国金融数字化“新”洞察行业研究报告
Huawei machine learning service speech recognition function enables applications to paint "sound" and color
Record a Webflux application memory leak troubleshooting
Redis source code analysis skip list
7-2 后序+中序序列构造二叉树
Yyds dry goods inventory tells us 16 common usage scenarios of redis at one go
RT thread uses RT kprintf
无鸟用的SAP PA证书,刚入行的同行可以考一考
安装IBM CPLEX学术版 academic edition | conda 安装 CPLEX
抖音实战~项目关联UniCloud
OpenSSL SSL_ read: Connection was reset, errno 10054
376. Tâches mécaniques
Spark's wide dependence and narrow dependence yyds dry goods inventory