I can't play more than one sound per page.
I created 2 instances of MediaElement, and each one, I set to play, but it only play one!
How can I solve this please?
If you add a reference to Microsoft.Xna.Framework to you project, you can use SoundEffect.Play to play mulitple sounds at the same time.
Add a event handler for MediaEnded to your first MediaElement control. In that event handler, start playing the sound on the second MediaElement using mediaElement2.Play().
Related
I want to create a custom GTK Assistant with my own buttons to control moving forward and back pages. I also don't want to end the program so the pages will be constantly looped through.
I haven't been able to find anything on line about this, any help would be appreciated.
Or if there another good way to cycle through different pages/windows with buttons then that would also be appreciated.
At that rate, you might be better off with a GtkStack.
Then set your window to popup or undecorated.
Or for a harder way, you could subclass the whole GtkAssistant and create your own implementation.
You can set your GtkAssistantPageType to GTK_ASSISTANT_PAGE_CUSTOM and create page with your own buttons, but you should manage button's signal.
The other solution is the gtk_assistant_add_action_widget function.
In Windows Phone 7 Silverlight is there a way to be able to have a button that while I have it selected it calls on a callback function. Either that, or have to functions one for when the button is selected and one for when the button is released. Any ideas as how to do this?
Note that I have already looked at the the toolkit, and the gestures they provide do not include this.
Thanks!
you could look at this in-depth article on gestures:
http://windowsphonegeek.com/articles/WP7-GestureService-in-depth--key-concepts-and-API
specifically the Tap and hold gesture might work for you.
These events would be applicable:
•GestureBegin
The GestureBegin event.
public event EventHandler<GestureEventArgs> GestureBegin;
•GestureCompleted
The GestureCompleted event.
public event EventHandler<GestureEventArgs> GestureCompleted;
On MouseLeftButtonDown start a timer that will Tick until Button is released. Also, you have a control on timer tick Interval
Are you trying to create an action that is similar to the list item tilt effect. or like the video scrub bar. both of those operate when finger is down on the screen, then return to previous state when you remove your finger?
For future reference, and to save some future soul the frustration of why the heck MS didn't implement this in the first place as part of their SDK...
I ended up solving this problem by using ManipulationStarted to record the start time, and ManipulationEnd to record the end time of the gesture, and a separate thread to keep track of the ticks in between.
Windows Phone 7.1/7.5/Mango app.
I have four different MediaElements on the page.
One is played upon Load of the page.
Rest 3 I Play() it upon leftMouseButtonClick on different image element on the page.
I call Stop() in the MediaEnded event handler.
Issue: The last mediaElement in the top-down order won't play. So it's not the element itself bu the order of the element that is behaving weird.
I have read this where it talks about a single MediaElement which I don't understand.
Does anyone has any ideas on this?
Note: I don't have to play all sound at the same time. Only one sound at a time.
I found one reference that talks having single MediaElement only and dynamically set the Source in the code. I haven't tried it yet, will do soon.
To confirm your last sentence, you can only have one MediaElement per page. You'll have to consider changing the source from the code-behind (or using data-binding) instead of having a MediaElement for each piece of audio. Having multiple MediaElements won't throw an error, but it will just override the behaviour of the previously added one (like you're experiencing).
To set the audio from the code-behind, you can use either the SetSource (which accepts a stream) method, or the Source property which reads a Uri.
In my case, I get the error at the 6th media element. I try to put 14 Media Elements in a project (just to see what happens). You could also use SoundEffect from XNA if you really need to have a lot of sources playing at the same time or something
I have a WPF 4 and VB.net 2010 project. I am playing videos in a single mediaelement. This is what I need to do:
When the window first opens, I have the first video play just fine. However, it is after this video plays that I run into trouble figuring out how to do the following.
I need the video source to change immediately following a single play through of any video, and I need this video (henceforth referred to as an "ambient" video) to loop forever.
When a certain event happens, I need to change the video source again, have it play once through, and then go back to looping ambient video in step 1.
Here is the rub, however. Many of the video triggers are inside of If-Then or Select Case statements in code behind, so I'm not exclusively using simple WPF events such as "MouseUp" or "MouseEnter".
Also, all videos must play in the same mediaelement, for performance reasons.
Thank you in advance!
How do I do this?
The Source of the media element is a DependencyProperty, as such any changes to it will be immediately reflected in the UI.
If you combine this with the MediaEnded event that is fired, you can set the Source and your problem is solved.
When you hit the triggers in code, you can either call a method or fire an event. You will have to use some semblance of a State Pattern to deal with the other logic. As an aside, check out Programming Without Ifs, it's an awesome intro on how to avoid insane conditional logic.
I set the mediaelement's LoadedBehavior to "Play" and Unloadedbehavior to "Stop", then I was able to just change the source of the mediaelement itself in code, and put the video I needed played after every video into the MediaEnded event.
It turns out that MediaEnded does not fire automatically when the LoadedBehavior is set to "Manual", unless "Stop" is explicitly called in code.
I hate accepting my own answers, so Nate Noonen gets the bounty (he was going down the right alley originally)! TY!
I have a a bunch of WPF UserControls that internally trigger some animations upon user interactions. All animations have repeatbehavior = "true" and all animations have the same duration. Now I would like synchronize all those animations on one timeline so they are fading in and out in sync. No matter when the user triggerd the animations. For example if the animations all last 3 secs and the user triggers the 2nd animation 1.5 secs after the first, I still want the animations reach their maximum at the same time.
Maybe I can define a global time line in a global resource dictionary that all animations that are defined somewhere in the UserControls can use? Preferably XAML only.
Simply add all of your animations to a single TimelineCollection. Then add that TimelineCollection to your Storyboard.Children. Then they will all fire simultaneously.
XAML: impossible (as far as I know)
code: CompositionTarget.Rendering
Maybe my post can help you http://translate.google.it/translate?js=n&prev=_t&hl=it&ie=UTF-8&layout=2&eotf=1&sl=it&tl=en&u=http%3A%2F%2Fblogs.ugidotnet.org%2Fleonardo%2Farchive%2F2011%2F01%2F08%2Fsincronizziamo-le-animazioni-con-wpf.aspx&act=url (is in Italian and link is of Google Translate)