How do I get Windows Media Center to understand a new WMF file? - ms-media-foundation

I'm in the early stages of creating a MFT to decode a "new" container format video. I'm using the MPEG1Source sample from the Media Foundation SDK, and I have a mpeg1 sample. I changed the extensions in both to ".test" and registered the dll.
Windows Media Player can open the file (my breakpoints are hit and the video plays), but Windows Media Center doesn't- opening from the command line works when the file is .mpg, but not as .test. My breakpoints aren't hit; it doesn't look like it even tries to load the dll (Visual Studio doesn't report my dll being loaded in the output window).
This is 64-bit Windows 7; the dll is native 64-bit.
Is there some additional registration that needs to happen before Media Center will understand a new file type?

I tried using MFTrace to trace the Media Foundation calls- nothing
I tried using Event Viewer to trace Media Foundation- nothing
Finally, I tried Process Monitor- great success! Media Center does a registry scan of HKCU\Software\Classes\.test, HKCR\.test, etc, and looks for a key called "PerceivedType"- if it's "video", then it will play.
So I added the registry key HKEY_CLASSES_ROOT\.test\PerceivedType = video and it works!

Related

Xamarin - No resource Id shown or available in image properties

I am trying to embed an image in Xamarin and was expecting to see a resource Id appear in the properties of the image. It seems to be a problem that I cannot find an answer for. I have updated VS, JDK to 64 bit, updated Xamarin, cleaned rebuilt, restarted. I'm using the latest API (API 27 8.1)
I have checked the Xamarin forum and the VS forums and there is no answer available. In my code-behind I am writing the following:
bgImage.Source = ImageSource.FromResource("FoodSnapApps.Images.steps.jpg");
Obviously it wont work as the resource has no reference.
As always, any help will be greatly appreciated.
As stated here, in Xamarin forms local images must be loaded in the platform specific projects:
Image files can be added to each application project and referenced from Xamarin.Forms shared code. To use a single image across all apps, the same filename must be used on every platform, and it should be a valid Android resource name (ie. only lowercase letters, numerals, the underscore, and the period are allowed).
iOS - The preferred way to manage and support images since iOS 9 is to use Asset Catalog Image Sets, which should contain all of the versions of an image that are necessary to support various devices and scale factors for an application. For more information, see Adding Images to an Asset Catalog Image Set.
Android - Place images in the Resources/drawable directory with Build Action: AndroidResource. High- and low-DPI versions of an image can also be supplied (in appropriately named Resources subdirectories such as drawable-ldpi, drawable-hdpi, and drawable-xhdpi).
Windows Phone - Place images in the application's root directory with Build Action: Content.
Universal Windows Platform (UWP) - Place images in the application's root directory with Build Action: Content.
Then you can access them as follow:
In XAML: <Image Source="waterfront.jpg" />
In C#: var image = new Image { Source = "waterfront.jpg" };
I suggest you to read all that page of documentation to proper handling images in your Xamarin forms project.
HIH
I know it's an old question, but for people who may reach this page on future, code below works for me:
bgImage.Source="resource://FoodSnapApps.Images.steps.jpg"

Flex Image Source Server Side Flash and Air

I'm trying to run my flex application in the air runtime instead of flash runtime. It seems to work perfectly except the images. Adobe Air runtime tries to load them. Is there a way to change the root adresses for Image to server side? If possible I'd like to use the same code for flash runtime and air runtime .. "single codebase ;-)"
var icon:Image = new Image();
icon.source = "images/test.png";
regards
cyrill
Typically I would simply package the assets into the AIR app. That way the relative paths would be valid both in the web app and the desktop app. However, since you pointed out in the comments that we're talking 10000 images you'll have to find another solution.
What you need is a variable that is configurable for each type of project. The final code to access your images should look like:
var icon:Image = new Image();
icon.source = rootUrl + "/images/test.png";
That rootUrl may be "" for the web app, and "http://www.mydomain.com" for the desktop app. Or it could be the absolute path in both cases. It doesn't matter: we don't want to hardcode that URL into our application.
Create a .properties file (or XML, or JSON; whatever configuration file you like) that contains the value for rootUrl and read that into your application model. This configuration file can be packaged into the AIR app.
A .properties file will look like this:
#myapp.properties
rootUrl=http://www.mydomain.com
For reading the file, you could use AIR's file streaming capabilities, but I suggest you load it the old-fashioned way with a URLLoader: this way it'll work both in the web and the desktop app.

ASP.NET Sound Resource not publishing

So I created an ASP.NET 4 application in VS2010, that needs to play sound to the end user, and it is working perfectly in my local development environment. The problem is the sound resource nor the Resources.resx is not being published to the server. Any idea why?
What I did:
1) Under Project  Properties  Recources I added my sound resource called: soundbyte (containing soundbyte.wav). I noticed this creates a Resource folder with the wav file and under my project a Resources.resx file referencing the file
2) In my code I play the file as follows:
Dim audioFile = My.Resources. soundbyte
Dim player = New Media.SoundPlayer(audioFile)
player.Load()
player.Play()
In the Visual Studio Solution Explorer right-click on Resources.resx and select Properties. Build Action. Set to content.
EDIT: The following resource might also help.
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
Ultimately, I found a way to play the sound to the client browser (as opposed to the server the asp app is running on) was to follow the techniques in this example: http://www.vbdotnetheaven.com/UploadFile/scottlysle/PlaySoundsInASPX09032006083212AM/PlaySoundsInASPX.aspx
But I found an even better way in my case was to use Javascript, which doesnt' require the Resources technique.
simply embed the sound on the page after the tag:
<embed src="Sounds/jump.wav" autostart=false width=1 height=1 id="sound1" enablejavascript="true">
Then in javascript setup the function:
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
Finally play the sound in the browser as needed in Javascript:
EvalSound('sound1');

loadMovieNum in AS2/1 files loaded into an Air-based AS3 / Flex application

I am working with a very large number of legacy SWFs written in AS1 and AS2. These SWFs use loadMovieNum extensively.
I am trying to integrate these into a new Air-based app (written in either AS3 or Flex). However, loadMovieNum doesn't seem to work within the Air app.
For example, an AS2 SWF (file1.swf) may try to load another AS2 SWF using:
loadMovieNum("http://127.0.0.1/file2.swf", 5);
This works fine if the SWF is played indepedently but if it is played from within the Air app, it fails.
EDIT: What happens in the Air app is that file1.swf will load successfully but silently fails to load file2.swf. There are no errors and no exceptions. A try...catch around the loadMovieNum reports nothing and file1.swf continues to play.
The relevent code from the Air app is as follows:
AS3 version:
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("http://127.0.0.1/file1.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.load(mRequest, loaderContext);
function onCompleteHandler(loadEvent:Event):void
{
// Add to the stage
addChild(mLoader.content.parent);
}
Flex version:
<mx:SWFLoader id="swfObj" source="http://127.0.0.1/file1.swf" />
It is simply the case that loadMovieNum will not work in Air? Or is there something that can be done. Obviously, making extensive changes to the legacy SWFs is, in all liklihood, not possible.
Thanks in advance.
I've concluded that _levels are not supported in SWFs that are loaded directly into Air apps. For example, even _level0 (which should always be defined) returns as undefined. Consequently, it would appear very unlikely that loadMovieNum would be supported.
I have discovered a workaround, though. Using the HTML browser component in Air, a webpage - in which the AS2/1 SWFs are embedded - can be loaded into the Air app. If you do this then loadMovieNum works as expected in the AS2/1 files.
AS3 version:
var hLoader:HTMLLoader = new HTMLLoader();
addChild(hLoader);
hLoader.width = stage.stageWidth;
hLoader.height = stage.stageHeight;
hLoader.load(new URLRequest("file1.html"));
Flex version:
<mx:HTML id="minibrowser" width="100%" height="100%" location="file1.html" />
Unfortunately, the HTML component is not supported by all Air profiles. In particular, in my case, it is not supported by the TV profile.
Although it may not seem intuitive, this seems like a security issue. When AS2 content loads up other AS2 content, they have to be in the same security sandbox in order for them to run.
I created a quick sample just to test this theory and I was right. The reason it works in Flash is because the AS2 content is in the same sandbox as the content it is loading. But AIR security is different. So when you load up the AS2 content in AIR (using the logic you supplied), the loader gets put in the application sandbox. The sandbox is now different than the content it is loading, so it refuses to load them.
This explains why it works when using an HTML wrapper. When the HTML loads up the swf, it probably gets put in the local-with-network sandbox which is the same as the content.
So... How do you fix it?
You can try to load your content up in a different security sandbox. But really the problem is that AS3 security isn't playing nice with the AS2 security. My suggestion would be to create the AIR application without an AS3 wrapper. You can't do this directly in the tooling, but you should be able to use the ADT packager to do it. In the xml descriptor, make the initial content the AS2 swf, and package it together. Now when you launch your AIR application it uses the AS2 swf as the main application. Suddenly your files should all be in the same security sandbox, and Flash won't prevent any of the content from running.
You can test this locally by using ADL to launch the app instead of launching it directly from Flash Professional or Flash Builder. (They both use ADL, but if you call it directly you have more control over the arguments used.)
EDIT: Apparently you can't have an AS2 swf as the main swf for Desktop AIR applications. (I've tested using ADL on desktop and it works, but I have been told that you won't be able to install an AIR application on desktop with this setup.) So for desktop you probably want to use the HTML workaround. This is supported in AIR for TV, so this would work on those devices.

Open local file with AIR / Flex

I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.
I am looking for a way to prompt the user to Open / Save As on a local file stored in the Application Storage Directory. I have tried using the FileReference + URLRequest classes but this throws an exception that it needs a remote url.
My last resort is just copying the file to their desktop : \
You can use the new openWithDefaultApplication(); function that's available on the File class (I believe it's only available in AIR 2)
eg:
var file:File = File.desktopDirectory.resolvePath(fileLocation);
file.openWithDefaultApplication();
Only way I could figure out how to do it without just moving the file and telling the user was to pass it off to the browser.
navigateToURL(new URLRequest(File.applicationStorageDirectory.nativePath + "/courses/" + fileName));
This is the first release of the FluorineFx Aperture framework.
The framework provides native OS integration (Windows only) support for AIR desktop applications.
The framework extends Adobe AIR applications in a non-intrusive way: simply redistribute the provided libraries with your AIR application, at runtime the framework will automatically hook into your application.
Features
Launch native applications and documents with the provided apsystem library
Take screenshots of the whole screen with the provided apimaging library
Access Outlook contacts from an Air application with the provided apoutlook library
http://aperture.fluorinefx.com/
Currently adobe is not supporting opening files in there default applications. Passing it off to the browser seems to be the only way to make it work.
You could however use a FileStream and write a small html file with some javascript that sets the location of an iframe to the file, then after 100ms or so calls window.close(). Then open that file in the browser.
For me it's:
var request:URLRequest = new URLRequest();
request.url = file.url;
navigateToURL(request, "_blank");
The navigateToURL(file.nativePath) didn't work since the path, "/users/mydirectory/..." was outside the application sandbox. AIR only allows some protocols to be opened with navigateToURL().

Resources