在手機拍攝視頻的時候,存在2個狀況,手機橫這和手機豎着。若是是橫着的狀況下,咱們豎着拿手機觀看模式,包括抖音,快手,他們的解決方案都是上下出現黑色變寬,對視頻進行等比例壓縮。老鐵我也參考這個來完成。另外若是用戶爲登陸的狀況下,想進入個人須要登陸才能夠,這個也須要頁面經過緩存中獲取用戶信息來進行控制。源碼:github.com/limingios/w… 中No.15前端
若是視頻的寬度大於高度,video的填充模式就修改成正常的狀況。不進行填充ios
var videoUtils = require('../../utils/videoUtils.js')
const app = getApp()
Page({
data: {
cover:'cover',
videoContext:"",
videoInfo:{},
videId:'',
src:''
},
showSearch:function(){
wx.navigateTo({
url: '../videoSearch/videoSearch',
})
},
onLoad:function(params){
var me = this;
me.videoContext = wx.createVideoContext('myVideo', me);
var videoInfo = JSON.parse(params.videoInfo);
var videoWidth = videoInfo.videoWidth;
var videoHeight = videoInfo.videoHeight;
var cover = 'cover';
if (videoWidth > videoHeight){
cover = '';
}
me.setData({
videId: videoInfo.id,
src: app.serverUrl + videoInfo.videoPath,
videoInfo: videoInfo,
cover: cover
})
},
showIndex:function(){
wx.redirectTo({
url: '../index/index',
})
},
onShow:function(){
var me = this;
me.videoContext.play();
},
onHide:function(){
var me = this;
me.videoContext.pause();
},
upload:function(){
videoUtils.uploadVideo();
},
showMine: function () {
var me = this;
var userInfo = app.getGlobalUserInfo();
if (userInfo.id == '' || userInfo.id == undefined){
wx.navigateTo({
url: '../userLogin/userLogin',
})
}else{
wx.navigateTo({
url: '../mine/mine',
})
}
},
})
複製代碼
判斷緩存中是否存在用戶信息,存在跳轉到我的信息頁面,不存在,跳轉到登陸頁面git
PS:小程序通常的開發思路就是儘可能前端能辦的少麻煩後端,減小交互。這樣用戶體驗就上去了。github