Multiple Flv Component playback - through a for loop - rewind issues AS3 Flash CS4 - flash-cs4

I am building a "video wall" app in flash AS3. I am importing a movie clip with a flvPlayback component nested within, then Adding it to the display list 12 times in a for loop (which is based on the length of an xml file.) The xml file aslo points to the .source of the flv instance.
This method is working, for displaying video content on all screens BUT, it only loops the last flvPlayback component. The rest just go back to the first frame of the video.
var vidURL = vidXML.video_item[i].#url
SS.video.source = vidURL;
SS.video.autoRewind = true;
SS.video.autoPlay = true;
SS.video.addEventListener(VideoEvent.COMPLETE, Loop);
function Loop(event:VideoEvent):void
{
SS.video.play();
}
I have tried refering to the SS + [i] to call the event to rewind as soon as it happens (as the videos are different lengths) but have had no luck.
Any help would be appreciated.
Thanks
Jono

Don't worry chaps...
using the "event.target.play()" is triggered when each video finishes, and rewinds them all nicely.
Sorry.
Jono

Related

Feed m4s files directly into SourceBuffer doesn't work

I downloaded some init MP4 file(init.mp4) and a sequence of m4s files(like 744397965.m4s, 744397966.m4s, 744397967.m4s...) from a live stream http://vm2.dashif.org/livesim/testpic_2s/Manifest.mpd using Dash.js.
Then I tried to feed these files directly into SourceBuffer bind with a video element, no pictures been played and no error thrown, why?
Did you seek the video element to the earliest timestamp in the resultant buffer (if it is not zero) and then call play() ?

Duplicate audio files in preloadjs manifest for LoadQueue

I am populating a manifest array for use by preloadjs's LoadQueue class. In the manifest, I am referencing sources to both audio and image files while creating unique ids for each. This all had been working great.
However, as the audio/image files are being selected from a CMS database (Wordpress custom post types), it may be the case that the same audio may be selected more than once. In other words, the same audio file may appear in the manifest more than once. When this happens, a very odd bug occurs where the last IMAGE reference in the resultant LoadQueue instance returns "undefined". It doesn't matter where the duplicate audio occurs in the manifest array, its always the last IMAGE object in the LoadQueue instance that returns undefined.
Duplicate image files do NOT cause a problem.
Is this a bug in preloadjs? (yes, it is of course wasteful to load more than one copy of the same audio file, but in my use case, we are talking about small files and a finite number of posts)
var manifest = [];
for (var i = 0; i < game_pieces_data.length; i++) {
manifest.push({id: "sound" + i, src: game_pieces_data[i].audio_url});
manifest.push({id: "image" + i, src: game_pieces_data[i].image_url});
}
preload = new createjs.LoadQueue();
preload.installPlugin(createjs.Sound);
preload.on("complete", handlePreloadComplete, this);
preload.loadManifest(manifest);
function handlePreloadComplete() {
var bitmap;
for (var i = 0; i < game_pieces_data.length; i++) {
bitmap = new createjs.Bitmap(preload.getResult('image' + i));
// bitmap.image.width <- will return undefined for last item of
// the loop if one of the audio files is a duplicate?
...
}
}
EDIT: I've determined that LoadQueue's "complete" event is firing before the final "fileLoad" event fires (the last image). This is the reason for the final image being undefined when asked for in my handler for the "complete" event. Again, this only happens when there is a duplicate audio file.
EDIT2: To further narrow down the issue, I've created a manifest that is only loading audio files and traced the "fileload" and the "complete" event. For every additional duplicate audio file, the number of "fileload" events fired for that file increases by 1 (2 dups = fileload fires 3 times for that file, 3 dups = fileload fires 4 for that file...etc). Additionally, an extra copy is added to the LoadQueue instances array of files (accessed by getResult).
However, the "complete" event will fire after the length of the manifest is reached, hence additional fileloaded events being fired after the complete event. The harm in this comes when you have a manifest with mixed files. In my case, my image files are getting pushed to the end of the queue by the extra duplicate audio files being made. And since "complete" fires correctly at the end of the length of the manifest, it fires before any image files being pushed to the end of the queue can be loaded causing errors in code expecting those file to be there after the queue completes.
I am working around this by creating 2 LoadQueue instances, one for the audio and one for images. When the audio queue "complete" fires, I create the image one and load those from a separate manifest. This is not idea however as it appears that there are now multiple useless duplicates of duplicate audio files in memory. And this number increase exponentially with each additional duplicate that may be selected in the CMS.

pop at the beginning of playback

When playing a memory stream containing wav encoded audio, the playback starts with a sharp pop/crackle:
ms = new MemoryStream(File.ReadAllBytes(audio_filename));
[...]
dispose_audio();
sound_output = new DirectSoundOut();
IWaveProvider provider = new RawSourceWaveStream(ms, new WaveFormat());
sound_output.Init(provider);
sound_output.Play();
That pop/crackle does not occur when playing the wav file directly:
dispose_audio();
NAudio.Wave.WaveStream pcm = new WaveChannel32(new NAudio.Wave.WaveFileReader(audio_filename));
audio_stream = new BlockAlignReductionStream(pcm);
sound_output = new DirectSoundOut();
sound_output.Init(audio_stream);
sound_output.Play();
Same file is playing, but when the wav data are stored in a memory stream first, there is a somewhat loud pop at the beginning of the playback.
I am very much a newbie with NAudio and audio in general, so it's probably something silly, but I can't seem to figure it out.
You are playing the WAV file header as though it were audio. Instead of RawSourceWaveStream, you still need to use WaveFileReader, just pass in your memory stream.

Detecting Front and Back camera in windows 8 tabs

I am developing a metro style app using c# and xaml. For a particular task i need to detect which cam(front or back) is currently capturing. Is there any way to detect front cam or back cam in winrt. Please help me.
Using indexes on the DeviceInformationCollection won't be a reliable solution:
Sometimes front camera will be index 0 and sometimes 1, after testing on the surface 2 a few times it seems to be kind of random.
User could use the USB port to connect an other webcam so you could end up with more than 2 items in your collection without any clue which camera is which index.
Having the same problem as you this is how I solved it:
// Still need to find all webcams
DeviceInformationCollection webcamList = await eviceInformation.FindAllAsync(DeviceClass.VideoCapture)
// Then I do a query to find the front webcam
DeviceInformation frontWebcam = (from webcam in webcamList
where webcam.EnclosureLocation != null
&& webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front
select webcam).FirstOrDefault();
// Same for the back webcam
DeviceInformation backWebcam = (from webcam in webcamList
where webcam.EnclosureLocation != null
&& webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back
select webcam).FirstOrDefault();
In this exemple I used Linq queries but it works the same with a foreach on "webcamList".
Just look on each DeviceInformation the .EnclosureLocation.Panel property, which is a Windows.Devices.Enumeration.Panel enum. The rest is obvius, Front for the front camera, Back for the back one.
Be also carefull to check if .EnclosureLocation is null or not, using an USB webcam it seems to be null most of the time.
You can use this code.
DeviceInformationCollection videoCaptureDevices = await eviceInformation.FindAllAsync(DeviceClass.VideoCapture);
If the videoCaptureDevices count is zero ,there is no camera attached.
And if camera count is 2 , then there will be both Front & back cameras.
If you initializing camera operation with videoCaptureDevices [0], that will be using Front Camera, and will be Back Camera if it is using videoCaptureDevices [1] .

What is the easiest way to get track data off a simple USB HID magnetic card reader?

I need to get Track 1 and Track 2 data off magnetic cards and send them over the network to a waiting server. What is an easy way to get the track data from a USB HID magnetic card reader?
In case it helps, I have a MAGTEK Mini Swipe Magnetic Strip Reader (part no. 21040140)
I'm OS agnostic -- a solution for Windows, Mac or Linux would be great. Preferably no .NET, but if that's the easiest way I'll go for it.
What do you all think?
Thanks!
Every card reader I've seen has had a keyboard emulator, so you swipe the card and it sends characters through the keyboard buffer. Looks like this one also does that (documentation : http://www.magtek.com/documentation/public/99875206-16.01.pdf)
Page 14 describes the data sent after a swipe, which is again, fairly standard across card readers:
[Tk1 SS] [Tk1 Data] [ES] [Tk2 SS] [Tk2 Data] [ES] [Tk3 SS] [Tk3 Data] [ES] [CR]
So your track one data starts with % and ends with ?
Track two data starts with ; and ends with ?
I noticed the question was tagged credit-card though, so it would be worth making sure you know the consequences of sending raw card-data across a network (even an internal network). Take a look at the Payment Card Industry Data Security Standards (PCI-DSS) : https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml
There is a demo program for that specific reader that comes with VB source.
http://www.magtek.com/support/software/demo_programs/usb_swipe_insert.asp
Easiest way to download the Cab file from this link & include it in the project directory in a "magtek" folder.
http://www.magtek.com/support/software/demo_programs/card/usb_hid_swipe_readers/read_parse.asp
Add this code in aspx file after tag (change cab file src as per )
<object id="USBHID" classid="CLSID:22571E97-956A-4CDD-AF8D-AE9C26597683" codebase="magtek/99510060.CAB#version=1,13,0,2">
</object>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#txtNameFirst').focus(); // Focus on a textbox is required
USBHID.PortOpen = true;
if (USBHID.PortOpen == false) {
$('#<%= lblStatus.ClientID %>').text('Could not open MagTek reader');
}
else {
$('#<%= lblStatus.ClientID %>').text('Please Swipe a card');
}
});
$("#txtNameFirst").bind('change', function () {
var CCData = $("#txtNameFirst").val(); // CCData will contain the complete credit card data in a string.
alert(CCData);
$("#txtNameFirst").val(CCData.split('^')[1].split(' ')[0]);
$("#txtNameLast").val(CCData.split('^')[1].split(' ')[1]);
$("#txtCCNo").val(CCData.split('^')[0].substring(2, 18));
//alert(' Split1: ' + CCData.split('^')[1] + ' Split2: ' + CCData.split('^')[2]);
//alert('parsing good!');
$("#txtExpiDt_RoutingNo").val(CCData.split('^')[2].substring(2, 4) + '/' + CCData.split('^')[2].substring(0, 2));
});
</script>
As per the above code I have added focus on a text box . After swiping the card focused textboxes automatically show the complete credit card data string.