Embedding metadata time limit for Flash Builder 4.5.1mobile project? - apache-flex

I am working on a project that requires me to embed metadata on the fly with a recorded stream from a webcam. I am utilizing Flash Builder 4.5.1 creating a mobile project. I am using a simple netStream.send function to set the metadata I want. This works just fine until my netstream time goes over around 10 seconds, then the function ceases to work or will not embed into the video. All my connections are correct and I can record to the Flash Media Server
The only thing I can think of is that my Flash Media Server 4 Developer is being over loaded and does not compute the metadata I send.
Any ideas would greatly help.
private function sendMetadata():void {
infotxt.text += 'called';
trace("sendMetaData() called")
myMetadata = new Object();
myMetadata.customProp = "This message is sent by #setDataFrame.";
myMetadata.customOther = cueHolder;
ns.send("#setDataFrame", "onMetaData", myMetadata);
}
And here is my onMetaData function
public function onMetaData(info:Object):void {
trace("caught");
infotxt.text = 'caught';
var key:String;
for (key in info){
outputWindow.text +=(key + ": " + info[key] + "\n");
}
//cueHolderReturn = info.customOther;
for (var i:int = 0; i < info.customOther.length; i++)
{
infotxt.text += info.customOther[i]
}
//infotxt.text = info.customOther[0];
}

Just wondering - is this problem occuring on both a real mobile device and a mobile emulator? If not, it could be the mobile connection - HTH

Related

Xamarin Forms NAudio

I need some advice.
I found this ShazamApi project that uses NAudio. I need this project to work in Xamarin Forms (Android), but I don't know what to use instead of NAudio to make it work on Android. Someone would know how to do it. Thanks a lot.
Specifically, I have a problem with this code.
https://github.com/AlekseyMartynov/shazam-for-real/blob/master/Program.cs
https://github.com/AlekseyMartynov/shazam-for-real/blob/master/Analysis.cs
public void ReadChunk(ISampleProvider sampleProvider)
{
if(sampleProvider.Read(WindowRing, WindowRingPos, CHUNK_SIZE) != CHUNK_SIZE)
throw new Exception();
ProcessedSamples += CHUNK_SIZE;
if(ProcessedSamples >= WINDOW_SIZE)
AddStripe();
}
WasapiLoopbackCapture capture = new WasapiLoopbackCapture();
var captureBuf = new BufferedWaveProvider(capture.WaveFormat);
capture.DataAvailable += (s, e) =>
{
captureBuf.AddSamples(e.Buffer, 0, e.BytesRecorded);
};
capture.StartRecording();
using (var resampler = new MediaFoundationResampler(captureBuf, new WaveFormat(Analysis.SAMPLE_RATE, 16, 1)))
{
var sampleProvider = resampler.ToSampleProvider();
var retryMs = 3000;
var tagId = Guid.NewGuid().ToString();
while (true)
{
while (captureBuf.BufferedDuration.TotalSeconds < 1)
Thread.Sleep(100);
analysis.ReadChunk(sampleProvider);
if (analysis.StripeCount > 2 * LandmarkFinder.RADIUS_TIME)
finder.Find(analysis.StripeCount - LandmarkFinder.RADIUS_TIME - 1);
if (analysis.ProcessedMs >= retryMs)
{
var sigBytes = Sig.Write(Analysis.SAMPLE_RATE, analysis.ProcessedSamples, finder);
var result = ShazamApi.SendRequest(tagId, analysis.ProcessedMs, sigBytes).GetAwaiter().GetResult();
if (result.Success)
return result;
retryMs = result.RetryMs;
if (retryMs == 0)
return result;
}
}
}
but I don't know what to use instead of NAudio to make it work on
Android.
In xamarin forms, you can use Xamarin Community Toolkit MediaElement to achieve this function.
MediaElement is a view for playing video and audio. Media that's supported by the underlying platform can be played from the following sources:
The web, using a URI (HTTP or HTTPS).
A resource embedded in the platform application, using the
ms-appx:/// URI scheme.
Files that come from the app's local and temporary data folders,
using the ms-appdata:/// URI scheme.
The device's library.
There is also a official sample here: Xamarin Community Toolkit - MediaElement.
Note:
In android, you can also try Android Audio. The Android OS provides extensive support for multimedia, encompassing both audio and video.

BluetoothLEAdvertisementWatcher not returning Service data UUIDs

I am writing a UWP application, I am using the BluetoothLEAdvertisementWatcher method to capture advertising from BLE devices around. This all works fine and I can build a list of devices by capturing the BluetoothLEAdvertisementReceivedEventArgs..... like below
private async void LockerAdv_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
ServiceUuidsFound += args.Advertisement.ServiceUuids.Count;
Adverts.Add(args);
However, I want to capture the ServiceData UUIDs carried in the advertising data (in our case 0x180f for the battery service data and 0xb991 for our own service data).
If I capture the advertising and examine the Advertisement.ServiceUuids.Count as shown above the count is always zero even though I know there are two ServiceData UUIDs present and Apps like the Nordic nRF app finds them and displays them.
Also, if I use the debugger to stop execution and examine the Advertisement.ServiceUuids then they appear not to have been captured and are certainly not accessible as can be seen below:
Link to screenshot.
I have tried using
ScanningMode = BluetoothLEScanningMode.Active;
and
ScanningMode = BluetoothLEScanningMode.Passive;
and it makes no difference.
Ultimately what I want is to be able to extract the ServiceData from the advertising data as it contains useful data for our application but if Windows won't even report the existence of the UUIDs then I am certain I can't get the data associated with it!!
So, what I need to know is it me doing something wrong? is it a limitation of Windows 10 (I am using the very latest version)? or is it perhaps an issue with the Dell Optiflex I am using?
Any help would be gratefully received
You are doing noting wrong. The debugger and watch just don't let you dig down deeper and show no native view.
Put the items you need in a list first and after that you can find out if the lists contain the items and even other collections with more items.
below is an example that shows you how. I think it does not cover all items, thats up to you:
private async void OnAdvertisementReceivedAsync(BluetoothLEAdvertisementWatcher watcher,
BluetoothLEAdvertisementReceivedEventArgs eventArgs)
{
//we have to stop the watcher to get the data from one advertising device only.
var device = await BluetoothLEDevice.FromBluetoothAddressAsync(eventArgs.BluetoothAddress);
if (device != null)
/* Check all advertisement items for null!
* Not all of them are present!
* Null check is not done in this example!*/
{
var TimeStamp = eventArgs.Timestamp.DateTime;
var LocalName = eventArgs.Advertisement.LocalName;
var Name = device.Name;
var BleAdress = eventArgs.BluetoothAddress;//ulong
var Rssi = eventArgs.RawSignalStrengthInDBm.ToString();
var ConnectionStatus = device.ConnectionStatus;
var Access = device.DeviceAccessInformation.CurrentStatus;
/* Shows advertising flags:
LimitedDiscoverableMode = 1,
GeneralDiscoverableMode = 2,
ClassicNotSupported = 4,
DualModeControllerCapable = 8,
DualModeHostCapable = 16.
*/
var flags = eventArgs.Advertisement.Flags.ToString();
var AdvNumberOfDataSections = eventArgs.Advertisement.DataSections.Count;
/*AdvDataSections contains the advertisement data */
List<BluetoothLEAdvertisementDataSection> AdvDataSections = new List<BluetoothLEAdvertisementDataSection>();
foreach (var item in eventArgs.Advertisement.DataSections)
{
AdvDataSections.Add(item);
}
List<BluetoothLEManufacturerData> AdvManufacturerData = new List<BluetoothLEManufacturerData>();
foreach (var item in eventArgs.Advertisement.ManufacturerData)
{
AdvManufacturerData.Add(item);
}
List<GattDeviceService> ServicesList = new List<GattDeviceService>();
var services = await device.GetGattServicesAsync(BluetoothCacheMode.Uncached);
if (services != null)
{
foreach (var item in services.Services)
{
ServicesList.Add(item);
}
}
}
/* Start the watcher again to get other devices or missing services or data */
}

AIR - NativeProcess With Sytem Profiler On Mac

I'm attempting to use Adobe AIR NativeProcess in a Flex application to generate an XML file that I can parse to get various system information on a Mac (I have the equivalent working on Windows and I'm not very familiar with the Mac). I need information mostly about the CPU.
I'm unable to call the system profiler and pass the proper parameters (or any parameters) to get the NativeProcess to execute properly.
If I set the NativeProcess executable to:
/Applications/Utilities/System Profiler.app/Contents/MacOS/System Profiler
it executes, but I see the results popup on screen (it ignores my arguments to save it to a file which I believe makes sense since it is the GUI version).
If I set the NativeProcess executable to:
user/sbin/system_profiler or just system_profiler
nothing executes and I receive an ArgumentError #2004 on the line where I assign the executable.
The parameters are something like this:
systemDataMac.npArgList = ["-xml",">", systemDataFileName,"-detailLevel","basic"];
How can I get this file generated properly (or is there any other way to get the CPU information directly into my Flex/AIR app?
Thank you!
Sample Code:
var nativeProcess:NativeProcess=new NativeProcess();
var startupInfo:NativeProcessStartupInfo=new NativeProcessStartupInfo();
var npArgs:Array = [];
var appDataDir:File = File.applicationStorageDirectory;
var nativeFilePath:String = appDataDir.nativePath.toString();
nativeFilePath+= File.separator + "systemInfoFile.xml";
nativeProcess.addEventListener(NativeProcessExitEvent.EXIT, onExit);
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, onInputIOError);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onOutputIOError);
try
{
// tried each of these three
startupInfo.executable=new File("system_profiler"); // throws error
startupInfo.executable=new File("/user/sbin/system_profiler"); // throws error
startupInfo.executable=new File("/Applications/Utilities/System Profiler.app/Contents/MacOS/System Profiler"); // works but doesn't handle args because it is the GUI version I believe
npArgs = ["-xml",">", nativeFilePath,"-detailLevel","basic"];
var args:Vector.<String>=new Vector.<String>();
for each(var item:String in npArgs)
{
args.push(item);
}
startupInfo.arguments=args;
nativeProcess.start(startupInfo);
}
catch (error:IllegalOperationError)
{
trace("Illegal Operator Error - " + error.toString());
}
catch (error:ArgumentError)
{
trace("Arg Error - " + error.toString());
}
catch (error:Error)
{
trace("Error - " + error.toString());
}
What kind of information do you need? Have you had a look at the Capabilities class?

Flex 3 & Air 2: Automatically detect when files on a directory are updated

A crazy idea just dropped from the sky and hit me in the head xD. I was wondering if it is possible to make and App capable of listening when the user "adds" new files to a directory.
Example:
The User opens up our Application.
The user adds new files on the desktop (using the Microsoft Explorer).
Our application automatically detects that new files have been added and executes a function or whatever.
Sound interesting right?
Maybe, this could be done using a programming language like Visual Basic and open the executable with the NativeProcess api and listen for an stdOut event... (:
Anyone got and idea to share with us? :)
Thanks
Lombardi
AIR can handle this natively...
the FileSystemList class fires an event directoryChange whenever a file in the watched directory changes.
You can even use it to watch for drives being mounted (I think Christian Cantrell showed that one off)
Ok, I think I'm getting closer, check out this solution! :)
private var CheckDelay:Timer = new Timer(5000, 0);
private function InitApp():void
{
CheckDelay.addEventListener(TimerEvent.Timer, CheckForNewFiles, false, 0, true);
CheckDelay.start();
}
private function CheckForNewFiles(event:TimerEvent):void
{
var FS:FileStream = new FileStream();
var Buffer:File = File.applicationStorageDirectory.resolvePath("FilesBuffer.cmd");
FS.open(Buffer, FileMode.Write);
FS.writeUTFBytes("cd " + File.desktopDirectory.nativePath + "\r\n" +
"dir /on /b > " + File.applicationStorageDirectory.resolvePath("FileList.txt").nativePath);
FS.close();
var Process:NativeProcess = new NativeProcess();
var NPI:NativeProcessStartupInfo = NativeProcessStartupInfo(); // What a large name! xD
NPI.executable = Buffer;
Process.start(NPI);
Process..addEventListener(NativeProcessExitEvent.EXIT, ReadFileList, false, 0, true);
}
private function ReadFileList(event:Event):void
{
var FS:FileStream = new FileStream();
var Buffer:File = File.applicationStorageDirectory.resolvePath("FilesBuffer.cmd");
FS.open(Buffer, FileMode.Read);
var FileData:String = FS.readUTFBytes(FS.bytesAvailable);
FS.close();
var FileArray:Array = FileData.split("\r\n");
var TempArray:ArrayCollection = new ArrayColletion();
var TempFile:File;
for(var i:int = 0;i<FileArray.length;i++){
TempFile = new File(FileArray[i]);
TempArray.addItem(TempFile);
}
}
At the end we got an Array (TempArray) that we could use on a datagrid (for example) with colums like: "extension, File Name, FilePath, etc.."
The files are updated every 5 seconds.
And, why we use all that code instead of a simple "File.getDirectoryListing()"? Because we are updating our application every 5 seconds, if why use getDirectoryListing(), our application will take much more RAM and also, the cmd command is much faster... :)
If you have a better idea, please share it with us! Thank you! :D
1 excellent solution for Windows: use Visual Studio, build the .net app found here http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
In Adobe AIR use the native process to listen for change events dispatched by .net

Get the status of a live stream for a VideoDisplay control

I'm looking for a way to find the status of a live stream through a VideoDisplay (or any other method really). I am interested to know if the stream is currently being published to or if the publisher has stopped. This is for a Flex/Flash ActionScript 3 project.
Is there a way to do this or is this ANOTHER oversight by adobe?
flex flash adobe adobe-flex actionscript
I've only found one solution, and that's using the NetStream object in combination with a video control.
The video control must be manually added to an
nsListen = new NetStream(nc);
nsListen.addEventListener(NetStatusEvent.NET_STATUS, nsListenHandler);
nsListen.play(streamname);
var v:Video = new Video();
v.attachStream(nsListen);
uicontrol.add(v);
Finally, the event status is returned in nsListenHandler:
private function nsListenHandler(e:Event):void
{
if(e is NetStatusEvent)
{
var nse:NetStatusEvent = NetStatusEvent(e);
if(nse.info.code == "NetStream.Play.Failed")
{
// Big error.
}
if(nse.info.code == "NetStream.Play.PublishNotify")
{
// Stream has just been published
}
if(nse.info.code == "NetStream.Play.UnpublishNotify")
{
// Stream has just been unpublished
}
trace(NetStatusEvent(e).info.code);
trace(NetStatusEvent(e).info.description);
}
}
Only this code wont do is tell you if a stream is already successfully being published to.
You can dig into NetStatusEvent events.
Check this live docs

Resources