恢复视频的发布

This commit is contained in:
cansnow
2026-02-15 19:40:36 +08:00
parent 7c6656d1fc
commit abd279e7a7
22 changed files with 236 additions and 129 deletions
+40 -18
View File
@@ -7,12 +7,16 @@ import {getVideoInfo} from "@/util/common";
import {downloadFile} from "@/uni_modules/network-manage";
// #endif
export const imapi = (method,data)=>{
console.log(method);
console.log(data);
return new Promise((resolve, reject) => {
IMSDK.asyncApi(method,IMSDK.uuid(),data)
.then(res=>{
console.log(res);
return resolve(res);
})
.catch(e=>{
console.log(e);
return reject(e);
})
});
@@ -64,7 +68,14 @@ export const getPurePath = (path)=>{
}
return path;
}
export const createVoiceMessage = async (path)=>{
export const createVoiceMessage = (path,duration)=>{
return new Promise(async(resolve, reject) => {
const message = await imapi(IMMethods.CreateSoundMessageFromFullPath,{
soundPath:getPurePath(path),
duration:duration
});
return resolve(message);
});
};
export const createFileMessage = async (path)=>{
};
@@ -83,11 +94,26 @@ export const getVideoCover = async (path)=>{
};
export const createVideoMessage = (path)=>{
return new Promise(async(resolve, reject) => {
const realVideoPath = await getPurePath(path);
console.log('处理后的可用路径', realVideoPath);
const info = await getVideoInfo(realVideoPath);
//const cover = await getVideoCover(path);
const res1 = await IMSDK.getVideoCover(path);
//console.log(res1.path);
const videoParams = {
videoPath: realVideoPath,
videoType: "mp4",
duration: info.duration,
snapshotPath: getPurePath(res1.path),
//snapshotPath: getPurePath(cover),
};
console.log('videoParams', videoParams);
const message = await imapi(IMMethods.CreateVideoMessageFromFullPath,videoParams);
return resolve(message);
//不想通过imsdk上传了,想自己上传,结果发现imsdk的上传接口不支持视频,所以只能通过imsdk上传了
console.log('处理前的可用路径', path);
//const realVideoPath = await copyFileToTempPath(path);
const realVideoPath = await getPurePath(path);
//console.log('处理后的可用路径', realVideoPath);
const info = await getVideoInfo(realVideoPath);
console.log('info', info);
const cover = await getVideoCover(realVideoPath);
console.log('cover', cover);
@@ -140,23 +166,28 @@ export const createVideoMessage = (path)=>{
//const cover = await getVideoCover(path);
//const res1 = await IMSDK.getVideoCover(path);
//console.log(res1.path);
const videoParams = {
const videoParams1 = {
videoPath: realVideoPath,
videoType: "mp4",
duration: info.duration,
snapshotPath: getPurePath(res1.path),
//snapshotPath: getPurePath(cover),
};
console.log('videoParams', videoParams);
message = await IMSDK.asyncApi(
console.log('videoParams', videoParams1);
const message1 = await IMSDK.asyncApi(
IMMethods.CreateVideoMessageFromFullPath,
IMSDK.uuid(),
videoParams
);
return resolve(message);
});
};
export const createImageMessage = async (path)=>{
return new Promise(async (resolve, reject) => {
const message = await IMSDK.asyncApi(IMMethods.CreateImageMessageFromFullPath,IMSDK.uuid(),getPurePath(path));
console.log(message);
return resolve(message);
//通过自己上传的方法实现的
const result = await upload(path,{savePath: "msg"});
if(result.code !=0){
uni.$u.toast(result.msg);
@@ -171,23 +202,14 @@ export const createImageMessage = async (path)=>{
url: result.data[0].file_url
};
const message = await IMSDK.asyncApi(IMMethods.CreateImageMessageByURL,IMSDK.uuid(),{
const message1 = await IMSDK.asyncApi(IMMethods.CreateImageMessageByURL,IMSDK.uuid(),{
sourcePicture: picBaseInfo,
bigPicture: picBaseInfo,
snapshotPicture: picBaseInfo,
sourcePath: result.data[0].file_url
});
console.log('message', message);
return resolve(message);
const tempPath = await copyFileToTempPath(path);
console.log(tempPath);
imapi(IMMethods.CreateImageMessageFromFullPath,getPurePath(tempPath)).then(res=>{
console.log(res);
resolve(res);
}).catch(err=>{
console.log(err);
reject(err);
})
console.log('message', message1);
return resolve(message1);
});
}
export const sendMessage = (message, user_id, group_id) => {