For size reasons I need to bundle a WP7 app with compressed audio (mp3, wma etc). How do I play these freely/simultaneously?
The XNA framework only supports WAV files, so unless there is a pure C# managed code library somewhere to decompress mp3/wma/ogg (?) on the fly, the next option would be...
MediaElement. But I don't get good results with MediaElement. It seems that you need to add a MediaElement specifically as a tag in the xaml, and you can't use several instances (several tags). As soon as I play a certain MediaElement I can't play another MediaElement on the same page. I don't find anything about a restriction in the reference (the reference is very empty).
I also tried dynamically creating MediaElement objects, but that doesn't seem valid at all, or I just cannot get it to play the files at all.
Use the built-in XNA content pipeline sound effect compression!
The default setting for a SoundEffect content type is "Best" compression quality (which appears to, in fact, be no compression at all). Set the compression quality to "Low" and you will get a much, much smaller file. Or "Medium" for a nice balance between size and quality.
To change this setting, select your .wav file in the solution explorer, press F4 to bring up the properties window, expand the "Content Processor" node, and change the compression quality setting that appears.
Here are instructions with screenshots:
Create a new WP7 XNA game project (or otherwise get an XNA Content Project)
Add a wav file to the content project:
Press F4 with the wav file selected in the Solution Explorer to bring up the properties window.
Expand the "Content Processor" node and change the compression quality to the desired setting.
A setting of "Best" gives no compression (raw waveform), settings of "Medium" and "Low" give a much smaller file.
In my experience currently there's no good solution for this on WP7. Either you use wavs with XNA and grow the size of the xap or use mp3s with the very limited MediaElement functionalty, compromising on what you can implement with it.
You might be able to port some C# audio libraries to WP7, I haven't heard of any so far so it might be long shot.
In one of my apps I finally decided to go with the wav + XNA combination after playing around with different options for a good while.
using Microsoft.Xna.Framework.Media;
void PlaySound(string pathToMp3) {
Song song = Song.FromUri("name", new Uri(pathToMp3, UriKind.Relative));
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
MediaPlayer.Play(song);
}
You could use MediaElement and set the source to the mp3, but this cannot be changed from code as in.
MediaElement me = sender as MediaElement;
me.Source = new Uri(
as you cannot load resources into the source.
you could use multiple MediaElements in your xaml and stop them and start the ones you require. As long as you predetermined which files you wanted to load at compile time.
You could also combine those files into one and play them at a particular location, like so.
me.Position = new TimeSpan(0, 0, 0, 0, 1);
me.Play();
Related
Is there a way I could store image url inside VTT file? For example:
WEBVTT
00:00:00.000 --> 00:00:10.000
Chapter tile goes here
thumb_0001.jpg
00:00:10.000 --> 00:00:20.000
Another chapter title
thumb_0002.jpg
I know I could write custom parser, but I am wondering is there some kind of a standard for this?
You would need to have a separate WebVTT metadata track, a player that supports them, and likely some scripting and CSS to act on the cue payload. You can see an AblePlayer demo of a few things a metadata track can do (at the 39 second mark). If you examine the wwa_meta.vtt file, you can see that it references ID selectors that happen to be in the player's page html code.
The example you give is quite similar to what is being done currently across the internet for image thumbnails. It's most commonly used for animated video previews on... adult... websites. If you Google search for ".jpg" filetype:vtt you'll find some interesting examples that take the same approach as yours.
As Murray cited already, it's not really the proper way to do it. The metadata track option he cites is much more inline with correct use of the VTT spec. However it's also not broadly supported. You could follow VTT guidelines and end up with a file that can't be read by many players.
One other option is CSS. VTT is designed to work nicely with CSS. So you could include you image as a CSS background-image. That way it's separate from the text content and (at least in theory) some players might even be able to display it properly.
I have setup a WMF session (built an IMFTopology object with a source pointing to a webcam and a standard EVR for screen output), assigned it to an IMFMediaSession and started a preview. All is working great.
Now, I stop the session (waiting for the actual stop), change the source's resolution (setting an appropriate IMFMediaType via its IMFMediaTypeHandler) and then build a new topology with that new source and a newly created IMFActivate object for the EVR. Also changing the output window's size to match the new frame size.
When I start that new session there's no image (or the image is garbled, or cut off at the bottom - depends on the change in resolution). It is almost as if the new topology is trying to re-use the previously setup EVR and it is not working correctly.
I tried setting that new media type on the EVR when generating a new one, tried to force the new window size on the EVR (via a call to SetWindowPos()), tried to get that output node by previously assigned streamID and set its preferred input format... Nothing worked - I get the same black (or garbled) image when I start the playback.
The only time the "new" session plays correctly is when I chose back the original source format. Then it continues as if nothing bad happened.
Why is that? How do I fix this?
Not providing the source code as there's no easy way to just provide the relevant parts. Generally my code closely follows the sample from MSDN's article on creating a Media Session for playing back a file.
According to MS's documentation the IMFMediaSession is managing the start/stop of the source so I'm relying on that when I'm changing the source's video format (otherwise the application fails).
If you want to build a real new topology, you need to release all MediaFoundation objects (source, sink, topology, and so on).
If not, it can be a little bit complicated.
I am trying to controlling the flow of an 3D animation on unity through the sound.
Therefore, through a synthesizer sounds, get the BPM of a song, which are stored in a file. Txt, with the given time and the number of BPM in second. Then in Unity, I have a pre-defined animation, and already carry the file with the information of BPM, but now I do not know how I can make the animation speed is controlled by the information in that file.
Any idea?
You can always change AnimationState.speed to serve that purpose.
http://docs.unity3d.com/ScriptReference/AnimationState-speed.html
When I install games on my computer professional and amateur I find that the resources such as pictures have strange extensions so I cannot open them.
As I cannot find these extensions on Google, I figured it was a method of protecting your artwork so it cannot be stolen so easily.
I have a bunch of JPEG, PNG and bitmap files I would like to do this to so people cannot copy them so easily when I distribute my game.
I use C++ and DirectX if that makes any difference.
Does anyone know how this is done? I know I can change a .txt extension to anything and my program will read it just the same but will this work with pictures?
As I cannot find these extensions on google I figured it was a method of protecting your artwork so it cannot be stolen so easily.
Creating your own extension is easy, just decide how you want to interpret your image, and create a converter to build them from existing images...
... But ... formats are chosen for the sake of the programmer and art tools, not for protection. You can't ever really protect your art from being stolen, as at some point your code will have to convert the graphics to a raw DDB (Device Dependent Bitmap) or DIB (Device Independent Bitmap) before rendering them to the screen or sending them to DX/OpenGL. Honestly, commercial games on cartridges that don't follow standard formats are easily ripped. Hackers even make level editors for proprietary game engines that aren't known to the public.
I don't use png's and jpg's in my game code for the simple reason that I was unable to use libpng in my code, nor a jpeg decoder, and I needed my graphics supplied in 8x8 tiles with 4/8-bit with palette (colour 0 is transparent), or 16-bit RGBA_555_1, which can't be achieved with png's and jpeg's.
At most, you can obscure your graphics by storing them in your own format, encrypting them or even compressing them, that's about it. But beware, your code will have to decrypt/decode it and the picture will at some point be in the thief's memory.
So yes, you can easily change the file type, but that will not stop any user from (a) changing the filename, or (b) figuring out the file type by putting it into a program that can easily recognize the file type. And as someone who's also done video editing, I can tell you that many programs will happily interpret any file and figure out the real format. And it won't stop (c), a scrupulous hacker from ripping your artwork. In fact just have a look at what hackers did with Propellerhead's Refill format, since they couldn't figure out how to read it, they created a program that used Propellerhead's program to read it - think about that. It really doesn't take much to use Vanjar Fukar's Debugger to trace your code when loading images, identify your image loading code, and either copy it, or invoke it themselves (amongst a hundred other hacking tactics).
Usually programs don't care about extensions when reading files, so changing extension to an unknown one shouldn't get you in trouble.
I want to make a simple assistant for putting together AviSynth scripts. This would be a windows desktop application that would have a "preview" screen of an avi movie, which would give you a timeline, play, fast-forward, rewind, advance and go back frame-by-frame. The program would need to know the frame number of the current frame in the player and its filename.
What language is best suited for this? I know PHP ( I understand that this is not a contender ) and am familiar with Java. My thought is that the biggest hurdle with this project will be finding a library for the video playing features. With a cursory glance, no Java video libraries jumped out at me. My next thought would be c++ for this.
The output of this program would be an AviSynth script, a plaintext file which looks like this:
AviSource("myAvi.avi")
Crop(0, 0, 320, 240)
Blur(0.1)
There are a few tool kits that can do tihs:
C#: DirectShow (DirectX)
Java: JMF
If you have Avisynth installed, the only thing you need for preview (If I understood, that's your need) is something that can decode uncompressed video. It would open like a normal file. I'm sure there are video players implemented fairly well in Java, but I don't know how much functionallity from them you need. Anyway parsing scripts is not easy - I recommend you not to try to if you don't need to.
EDIT: I'm sorry, I thought you needed a very specific app, but from what you seem to need, you don't need to code anything, use AVSP!
Please watch this video, it shows how straightforward it is. It has advanced functions such as auto-completion, (even from your own auto-loading scripts!) syntax coloring, macros, automtic importing, drag&drop (of a video, for instance - just drag it to the video and AVSP makes the loading) scrit preview with zoom and all stuff, you can use automatic or custom sliders (you can make a slider that re-writes a number on the script in real time, for instance for hue/luminosity/contrast/etc. that would be cumbersome to control via script), checkboxes & radio buttons (for boolean values, etc...), text fields that alter strings in real time, and basically anything you need... Please check it out.
Also, VirtualDubMod is OLD.
And yep, AVSP is free, both gratis and libre! =)