Hi, we are trying to rebuild some of where components from WPF to Web app (React), I was looking for way to handle video playback and live stream in web and I found out that you do have JavaScript SDK (but there is no documentation) and I found this GitHub repo that have web samples of handling similar stuff, but when I tried to run them on my machine, in the connect step i got 405 Method not allowed:
so if you can provide documentation of how to use it and please if you can help me with this error
Thanks for helping
Hello Abaas,
A great place to start is the MIP SDK Mobile Documentation. Navigate to the Web tab, then click on How to Host a Sample in the top left corner. There, you’ll find instructions on setting up your MobileServer and hosting samples. A simple way to create and work with your own samples is by setting up an Express server.
Let us know if this helps
Hi @Constantina Ioannou
Thanks a lot, that was super helpful.
I have one more question, I didn’t find in the samples a way to get the Live Messages Or Events like we have here in Smart Client Plugin:
MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
_messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
_register = _messageCommunication.RegisterCommunicationFilter(
OnNewEventReceived,
new CommunicationIdFilter(MessageId.Server.NewEventsIndication),
null,
EndPointType.Server
);
So is there a way or docs that can you help me with ?
Thanks a lot for helping
Yes, read the mobile server protocol so that you can get an understanding on how you can connect/login when you are creating samples.
For methods go through the XPMobileSDK, if you are trying to capture events/alarms that are initiated from other devices maybe the function registerForNotifications could be appropriate.
Hi @Constantina Ioannou
Thanks, that’s so helpful, but still if you can provide an example or documentation of how to use it will be awesome
Hi Abaas,
Could you provide more information on what you are trying to build, then maybe I can better guide you on what you need.
Hi @Constantina Ioannou
We currently have a video analytics tool that is using AI Bridge, we receive events and display them in real-time. We are currently using WPF and want to change to web app.
If you look at this code, where we will be able to receive the events or alarms in .Net SDK:
MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
_messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
_register = _messageCommunication.RegisterCommunicationFilter(
OnNewEventReceived,
new CommunicationIdFilter(MessageId.Server.NewEventsIndication),
null,
EndPointType.Server
);
We need the same thing in JavaScript SDK.
Thanks for helping
I understand, if you can trigger an alarm-event you can capture it with the following sample. For this sample to work make sure you have enabled the notifications on your mobile server, and setup an alarm-event that triggers
var $ = $ || {};
$.getBrowser = function () {
let browser = { name: ‘’, version: ‘’ };
return browser;
};
(function () {
‘use strict’;
if (!window.customElements) {
let script = document.createElement('script');
script.addEventListener('load', startApp);
script.src = 'js/polyfill-webcomponents-bundle.js';
document.querySelector('head').appendChild(script);
} else {
startApp();
}
function startApp() {
var params = {
connectionDidLogIn: function () {
var notify = {
receivedNotification : function(popup) {
//get notification and do something with it
console.log("RECEIVE NOTIFICATION", popup);
}
};
XPMobileSDK.addObserver(notify);
const flags = {
Unsubscribe: 0,
Subscribe: 1,
AllAlarms: 2,
MyAlarms: 4,
AccessControl: 8,
DenyInApp: 16,
DenyPush: 32
};
let setting = flags.Subscribe | flags.AllAlarms | flags.DenyPush;
var updateLiveMessageTimerAfterSubscribe = function () {
var minInterval = 3;
XPMobileSDK.library.Connection.updateLiveMessageTimer(minInterval \* 1000);
};
XPMobileSDK.registerForNotifications(setting, updateLiveMessageTimerAfterSubscribe, function () { });
}
};
LoginManager.loadAndLogin(params);
}
})();
@Constantina Ioannou
Hi, thanks for help, actually I need help with something else.
I need to access playback of the video from the Mobile server with JavaScript SDK, like get the playback from START and END Date and time. Can you help me with docs or reference
Hi @Constantina Ioannou
I did look into those samples, but they don’t contain Playback examples
Yes, you’re right - they’re not showing the playback version. One of the methods used in those samples for handling video is RequestStream which you can send with either live/playback parameter.
Also, you could take inspiration from Samples\lib\js\application.js file where it gives an idea of how to use
getAllViews and RequestStream methods"
I understand what you’re saying and i appreciate it, but I already look into all those, and they don’t fit with the project requirements.
I need to get the playback from and to a specific time.
Thanks for helping
Hi Abaas,
I am sorry to hear, I thought that would be helpful. Another thing to look into, I haven’t tried it myself, but when you use RequestStream there is a number of params you can sent to the server > Check XPMobileSDK.js line 793 - 830.
Maybe the following is among the lines you may need?
const params = {
ConnectionId: /* your connection id */,
CameraId: /* your camera GUID */,
SignalType: “Playback”,
TimeRestrictionStart: startTimeMs, // e.g., Date.now() - 3600000
TimeRestrictionEnd: endTimeMs, // e.g., Date.now()
// …other options as needed
};
XPMobileSDK.RequestStream(params, successCallback, failCallback);
Hi @Constantina Ioannou ,
Still not working, i get only the last frame of the last record, and btw i can’t read XPMobileSDK.js file because it bundled.
Thanks again for help
Hi @Constantina Ioannou
Can you help us with this issue please. if you do have docs or another examples except the ones on GitHub that will be helpful.
The problem i have is when i request playback from specific Date and Time, i always gets only the last frame from the last record exists on this camera.
Thanks again for help
Hi @Abaas Mahroos,
I see and talked to my colleague who responded to you on another thread. I believe that solution solves your issue including this one. If it did not, please open a new ticket.
Thank you
Constantina