How can I use code-generated images on my WinRT live tile? - vb.net

I'm trying to create live tiles in my app by using BitmapRender (in Windows 8.1) to create an image from a user control, which I then want to add as my live tile image.
Creating the image works perfectly, and I store it in the app's roaming folder. However, I can't get the image to add to the live tile when created this way. The odd thing is that if I copy my generated file into the project and then try to attach it to the live tile it works (so the image must be correctly formatted/size, etc.); and if I copy a random image into my roaming folder and set that as the live tile image it also works (meaning I am able to use a file in the roaming folder to set the tile image)...so that means I am referencing the file location correctly, and the image itself is capable of being used on a live tile...so why doesn't it work?
I have created a sample project (link below) that illustrates that my live tile creating code works (with an image stored in the project), and also that I can successfully create an image from a UI control and store it in the roaming folder (FWIW I've tried using different folders with no change in behaviour).
Is there something I'm missing? Any insight or help would be greatly appreciated.
Project is in VB.net, but I can figure out answers in C# if that's easier.
Sample project to illustrate the issue

The trouble is that you're attempting to use an absolute file path to reference the image, which is not supported. If you look in the tile schema, specifically at the page for the element, you'll see that the src must be an URI using http[s]://, ms-appx:///, or ms-appdata:///local for Windows Store apps. The fact that you can use a relative in-package path of /livetile.png is a bit of a fluke, as that's defaulting to ms-appx:///livetile.png.
What you need to do, then, is just use this for a filepath:
filepath = "ms-appdata:///local/livetile.png"
I tried this in your sample and it worked fine. Do note that only the local folder is supported here, not roaming. This is primarily because roaming appdata is limited to 100K to begin with, and dropping tile images in there would often quickly fill your quota. You'll want to then generate the image locally on each device (which would make sense also because you can then take the current scaling into account).

Related

Wallet pass fails to display if it has no images

I am trying to create an ios Wallet Event Ticket. I managed to give all the info I needed to create the pass.json and I have signed and zipped it. When I try to open this on a Mac, I am able to see the pass in the preview. When I email it and try to open it from an iPhone, the screen just goes to the main screen as if it crashed.
After lots of experimentation I found out that if I add at least one of t he images (icon) I am able to see it in preview and add it to the Wallet.
Since I do not care to add any image, this seems way too much just to make it work.
The question is, are images required in the pass? And if not, why does it not work without them. I repeat, it was displayed on Mac preview either with or without the image file.
Yes! manifest.json required the image correctly, moreover the pass.json also need to ensure everything is correct. Some elements must add in json for iPhone open, for example:serialNumber, webServiceURL, authenticationToken, relevantDate
Also, iPhone open .pkpass as difference format with mac. In my case , the signature file is wrong will also make the .pkpass file cannot open in iPhone.

How to play embedded video, by prevention of producing new video file in directory path?

I am developing vb.net Windows application for playing the video file.
I have added a video files in embedded resource in this way:
Project->Properties. Then select the "Resources" tab. Next Select
"Add Resource"->"From Existing File".
I am able to play the one video,with following code
Dim FilePath = Path.Combine(Application.StartupPath, "My video.mp4")
If (Not File.Exists(FilePath)) Then
File.WriteAllBytes(FilePath, My.Resources.video1)
End If
AxWindowsMediaPlayer1.URL = FilePath
AxWindowsMediaPlayer1.Ctlcontrols.play()
The video is working fine , but problem is, application creates the video file in the bin folder every time.
You can see here...
My application's Current exe size in 200 MB, as I have added many videos into the resources.
What the use of adding video into resources, if it going to produce new video file every time ?
I have did same thing with images, I have added images in resources
which used in the app,
but I don't req. to carry these images as well , it dont produce the image after running the app.
I can put the exe on any machine and app gets run with those images perfectly...
Is there any way to play the embedded video , from resource itself
without creating the video file ?
Some thoughts, then a possible solution:
I wouldn't recommend embedding large videos in your .exe as it creates a huge executable.
There's only so much you can do to prevent piracy. Even if you
prevent them from copying the local video file, they could still use
software to record their screen.
Having said that, what you'd ideally want to do is play from a memory stream instead of a file. But AxWindowsMediaPlayer can't play from a stream.
What you might be able to do is play it from a virtual file system which mimics a local file but in memory. Here's an SDK that allows you to do that: http://boxedapp.com/encrypted_video_streaming.html
From the documentation: Why and when is it useful? "When an application uses DLL and files, which are to be kept secure, and because of that you can't save them to disk"
They have examples for VB.Net including using the AxWindowsMediaPlayer.
Also, it does require purchasing a developer's license.

May I embed images as data URI with Windows 8/10 toast notifications?

I'm trying to write an application that offers toast notifications on Windows 8 and newer.
Is it possible instead of referencing an image file on the local disk to use data URIs in order to display an image via the XML that one passes to show the toast? I was unable to come up with any documentation so far and I am still in the research phase for my project (so no code to "simply" try, yet).
No. DataUris are not supported for images in toasts (or tiles)
Update/documentation/proof:
For 8
From https://msdn.microsoft.com/en-us/library/windows/apps/hh761494.aspx
In this set of templates, the image element is expressed using one of
these protocols:
•http:// or https:// A web-based image.
•ms-appx:/// An image included in the app package.
•ms-appdata:///local/ An image saved to local storage.
•file:/// A local image. (Only supported for desktop apps.)
And for 10
From https://msdn.microsoft.com/en-us/library/windows/apps/br230844.aspx
The URI of the image source, using one of these protocol handlers:
•http:// or https:// A web-based image.
•ms-appx:/// An image included in the app package.
•ms-appdata:///local/ An image saved to local storage.
•file:/// A local image. (Supported only for desktop apps. This protocol cannot be used by Windows Store apps.)
Bonus, on WP 8.X you couldn't even specify the image, it just used the app icon.

Setting ApplicationBarButton.IconUri with icon from Isolated Storage

I am working on windows phone application in which i need to change ApplicationBarButton icon dinamically, for example to show current date like in default Windows Phone Calendar app. Regarding to this article, we can use only png images previously added to solution and reference to them with relative Uri.
It is not a problem for me to generate correct png image (this way and using ToolStack C# PNG Writer Library) and save it to isolated storage, but when i'm initializing AppBarButton with absolute Uri to this image and trying to add it to ApplicationBar, my app throws ArgumentException.
Am i doing something wrong or i just have to draw 366 icons and add them to my project? :)
Thanks in advance!

How to load an image with unique names from a private folder?

I am working on an app for iPad where I want to have lets say 100 jpg's in a folder.
They could be named like 01.jpg, 02.jpg etc.
In my app I like to browse those images and when clicking on one of them I need the name of the image to be able to send some data over the network (the data part works fine).
I tried to use UIImagePicker but I found out there are no name connected to the actual image.
Then I made another approach where I have a number of pages where I have buttons and here I load in the images which works fine as long the are a part of the recourse of the project...
But here comes the real problem.
The user of the app should be able to change those images over time without recompiling the app.
So I do look for a way to have a folder where the user can place/replace images with the names 01.jpg etc and the app to use those updated images.
Ideas are very welcome.
Wiljan
I am not sure that I understand what you mean, but You can save images in your application documents folder. You can find more details at:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW6
You can also use NSFileManager to copy files.
what I suggest to do is :
put default images on project resources.
At first start, copy files to documents folder.
always use images from documents folder.