Video.js can't take video in mp4 - vue.js

I want to take a video in mp4. But with this.player.recordedData, I'm taking only mkv format and I can't change it. So I was trying to use something like:
console.log(this.player.record().video);
But it's giving the error:
[Vue warn]: Error in render: "TypeError: Cannot read property 'name' of undefined",
TypeError: Cannot read property 'name' of undefined.
Here are the options:
player: '',
options: {
controls: true,
autoplay: false,
fluid: false,
loop: false,
width: 320,
height: 240,
bigPlayButton: false,
controlBar: {
volumePanel: false
},
plugins: {
record: {
audio: true,
video: true,
debug: true,
videoMimeType: 'video/webm;codecs=H264'
},
},
},
mounted() {
/* eslint-disable no-console */
this.player = videojs('#myVideo', this.options, () => {
// print version information at startup
var msg = 'Using video.js ' + videojs.VERSION +
' with videojs-record ' + videojs.getPluginVersion('record') +
' and recordrtc ' + RecordRTC.version;
videojs.log(msg);
});
// device is ready
this.player.on('deviceReady', () => {
console.log('device is ready!');
});
// user clicked the record button and started recording
this.player.on('startRecord', () => {
console.log('started recording!');
});
// user completed recording and stream is available
this.player.on('finishRecord', () => {
console.log(this.player);
var myfile = this.player.recordedData;
const chunks = [];
chunks.push(myfile);
this.attachments.push({
file: this.player.recordedData,
uploaded: 0
});
});
// error handling
this.player.on('error', (element, error) => {
console.warn(error);
});
this.player.on('deviceError', () => {
console.error('device error:', this.player.deviceErrorCode);
});
}

Related

Create multiple windows with different html file using vite-electron-builder

I'm working on an app where my main window is type desktop, but opening a new window by clicking a tray opens the same index instead of opening the html file i want. If I add the file link by hardcoding it returns a white screen because vite can not complile vue and ts included in the html file.
I even added it to the input values of vite.config.js
vite.config.js
build: {
sourcemap: true,
target: `chrome${chrome}`,
outDir: 'dist',
assetsDir: '.',
rollupOptions: {
input: {
main: join(PACKAGE_ROOT, 'index.html'),
upload: './upload/upload.html', // file i want to compile with vite to make it work
},
external: [
...builtinModules.flatMap(p => [p, `node:${p}`]),
],
},
emptyOutDir: true,
brotliSize: false,
}
createSecondWindow.ts
async function createSecondWindow() {
const browserUploadWindow = new BrowserWindow({
//skipTaskbar: true,
movable: true,
roundedCorners: true,
titleBarStyle: 'default',
resizable: true,
hasShadow: true,
show: true, // Use 'ready-to-show' event to show window
height: screen.getPrimaryDisplay().size.height-300,
width: screen.getPrimaryDisplay().size.width-300,
minHeight:screen.getPrimaryDisplay().size.height-350,
minWidth:screen.getPrimaryDisplay().size.width-600,
enableLargerThanScreen: true,
webPreferences: {
nativeWindowOpen: true,
webviewTag: false,
preload: join(__dirname, '../../preload/dist/index.cjs'),
},
});
browserUploadWindow.on('ready-to-show', () => {
browserUploadWindow?.show();
if (import.meta.env.DEV) {
browserUploadWindow?.webContents.openDevTools();
}
});
const pageUrl = import.meta.env.DEV && import.meta.env.VITE_DEV_SERVER_URL !== undefined
? import.meta.env.VITE_DEV_SERVER_URL
: new URL('../renderer/dist/upload.html', 'file://' + __dirname).toString();
const uploadUrl = new URL('../renderer/upload/upload.html', 'file://' + __dirname).toString();
await browserUploadWindow.loadURL(uploadUrl);
return browserUploadWindow;
}
mainWindow.ts
async function createWindow() {
//browserWindow.setVisibleOnAllWorkspaces(true)
// let the dock be on top of the window
const browserWindow = new BrowserWindow({
type: 'desktop',
skipTaskbar: true,
roundedCorners: false,
titleBarStyle: 'hidden',
resizable: false,
hasShadow: false,
show: false, // Use 'ready-to-show' event to show window
height: screen.getPrimaryDisplay().size.height,
width: screen.getPrimaryDisplay().size.width,
enableLargerThanScreen: true,
webPreferences: {
nativeWindowOpen: true,
webviewTag: false,
preload: join(__dirname, '../../preload/dist/index.cjs'),
},
});
browserWindow.on('ready-to-show', () => {
browserWindow?.show();
if (import.meta.env.DEV) {
browserWindow?.webContents.openDevTools();
}
});
const pageUrl = import.meta.env.DEV && import.meta.env.VITE_DEV_SERVER_URL !== undefined
? import.meta.env.VITE_DEV_SERVER_URL
: new URL('../renderer/dist/index.html', 'file://' + __dirname).toString();
await browserWindow.loadURL(pageUrl);
return browserWindow;
}````

Uncaught ReferenceError: then is not defined in Element Ui Plus

I'm using the vue3 and element-ui-plus to build a project.
But when I tried to use the MessageBox in element-ui-plus, there was an error Uncaught ReferenceError: then is not defined coming out.
Other functions are good except MessageBox.
Here is my code. And Please refer to the handleDelete function.
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
const app ={
el: '#app',
data(){
return {
pagination: {
currentPage: 1,
pageSize: 10,
total: 0,
queryString: null
},
formData: {},
}
},
created() {
this.findPage();
},
methods: {
findPage() {
var param = {
currentPage: this.pagination.queryString == null ? this.pagination.currentPage : 1,
pageSize: this.pagination.pageSize,
queryString: this.pagination.queryString
};
axios.post("/checkitem/findPage.do",param).then(res => {
this.pagination.total = res.data.total;
this.dataList = res.data.rows;
});
},
resetForm() {
this.formData = {};
},
handleDelete(row) {
this.$confirm("Do you want to delete the record?","Warning",{
confirmButtonText: "Yes",
cancelButtonText: "No",
type: "warning"
}).then(() => {
console.log("delete record");
axios.get("/checkitem/delete.do?id="+row.id).then(res => {
});
}).catch(() => {
});
}
}
};
Vue.createApp(app).use(ElementPlus).mount("#app");
<script>
#Oliver you could try making your function async. See below
async handleDelete(row) {
try {
await this.$confirm("Do you want to delete the record?","Warning",{
confirmButtonText: "Yes",
cancelButtonText: "No",
type: "warning"
})
console.log("delete record")
axios.get("/checkitem/delete.do?id="+row.id)
} catch (error) {
// handle error
} finally {
// something else if you need
}
})
Question though, are you meant to be waiting for a user to confirm/cancel the click before you trigger execute the delete?

Vue JS if statement returns both outcomes

I am making a website with a login function. However, when you successfully log in, it tells you both that the login failed and that it succeeded. Here is the code that handles the login message:
log () {
const self = this
firebase.auth().signInWithEmailAndPassword(this.regname, this.passname).catch(function (error) {
console.log(error.code, error.message)
})
firebase.auth().onAuthStateChanged(function (user) {
const huser = !!user
if (huser === true) {
self.$router.push('/firstlogged')
self.$q.notify({
color: 'positive',
spinner: true,
timeout: 5000,
progress: true,
message: 'Login Success!',
actions: [
{ label: 'Dismiss', color: 'white', handler: () => { /* ... */ } }
]
})
} else if (huser === false) {
self.$q.notify({
timeout: 5000,
progress: true,
color: 'negative',
message: 'Login Failed, check your input',
actions: [
{ label: 'Dismiss', color: 'white', handler: () => { /* ... */ } }
]
})
}
})
},
Obviously, it should only send one of these messages. It does however work if you put in the wrong login details. Any fixes to this?

Vue-Tables-2 Side Server Get Error " Cannot read property 'data' of undefined" Why?

I am using vue-tables-2 for manage data. I wanna implement server side. But I got a problem. I can get the data as well. But I dont know why I got that error message. This is my code:
HTML
<v-server-table :columns="columns" :options="options"></v-server-table>
Vue Js
<script>
var config = {
"PMI-API-KEY": "erpepsimprpimaiy"
};
export default {
name: "user-profile",
data() {
return {
columns: ["golongan_name"],
options: {
requestFunction: function(data) {
return this.$http({
url: "api/v1/golongan_darah/get_all_data",
method: "post",
headers: config
}).then(res => {
this.data = res.data.data;
console.log(res);
});
},
filterable: ["golongan_name"],
sortable: ["golongan_name"],
filterByColumn: true,
perPage: 3,
pagination: { chunk: 10, dropdown: false },
responseAdapter: function(resp) {
return {
data: resp.data,
count: resp.total
};
}
}
};
}
};
</script>
This is the error:
enter image description here

I can't Integrat Sweet Alert After Axios Post action vueJs

i want to integrate this toast only if axios post is executed. i placed it like that and it's shown up even if my post axios function is not working.
how can i fix that ?
My code:
methods: {
addRinvoice: function () {
const toast = swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 9000
});
axios.post('/addrinvoice', this.rinvoice)
.then(response => {
toast({
type: 'success',
title: 'Invoice added in Database'
}),
console.log(response.data);
if (response.data.etat) {
this.rinvoice = {
id: 0,
amount: response.data.etat.amount,
};}})
.catch(error => {
console.log('errors: ', error)
}) },
Just put your call invoking the toast method inside your then() method:
methods: {
addRinvoice: function () {
axios.post('/addrinvoice', this.rinvoice)
.then(response => {
const toast = swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 9000
});
toast({
type: 'success',
title: 'Invoice added in Database'
}),
console.log(response.data);
if (response.data.etat) {
this.rinvoice = {
id: 0,
amount: response.data.etat.amount,
};}})
.catch(error => {
console.log('errors: ', error)
})
},
place it inside then after getting response successfully like :
then(response=>{
...
const toast = swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 9000
});
toast({
type: 'success',
title: 'Invoice added in Database'
}
}