|
Mohammad Dayyan wrote: Can we play a *.MP3 file in WPF (C#) ?
Yes.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mohammad Dayyan wrote:
Can we play a *.MP3 file in WPF (C#) ?
Yes.
Mohammad Dayyan wrote: Any ideas ?
Maybe do a google search on it, or search the article search here.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
You could also use the MediaPlayer class to access Window Media Player directly through C#.
MediaPlayer _mp3Player = new MediaPlayer();
_mp3Player.Stop();
Uri mp3 = new Uri(mp3fileLocation);
_mp3Player.Open(mp3);
_mp3Player.Play();
|
|
|
|
|
I also use SoundPlayer class ( I tested it for *.wav files )
|
|
|
|
|
I need to send a dll file using WCF Service. Please Help me for do this
Dushan Perera
|
|
|
|
|
You could always transfer it as a stream of bytes.
|
|
|
|
|
can u please explain how to do it.
Dushan Perera
|
|
|
|
|
Off the top of my head, it might look something like this:
public class DllFile
{
[DataMember]
public string FileName;
[DataMember]
public byte[] File;
}
[ServiceContract]
public interface IDownload
{
[OperationContract]
DllFile DownloadFile();
}
public class Download : IDownload
{
public DllFile DownloadFile()
{
DllFile dllFile = new DllFile();
dllFile.FileName = <<fullyqualified filename.dll>>
using (FileStream fs = new FileStream(dllFile.FileName, FileMode.Open, FileAccess.Read))
{
dllFile.File = new byte[(int)fs.Length];
fs.Read(dllFile.File, 0, (int)fs.Length);
return dllFile;
}
}
}
|
|
|
|
|
Thanks pal.I check it and see
Dushan Perera
|
|
|
|
|
Thanks Pal. It works.
Dushan Perera
|
|
|
|
|
|
Hello everybody.
Do we have a class with TimeSpan? name in WPF ?
If so, what's that ?
Thank you.
|
|
|
|
|
This is a standard .NET type (the ? at the end means it's nullable). Basically, a TimeSpan is a representation of a period of time, and can be set up based on different intervals.
|
|
|
|
|
Thanks for Helping me Guys. i had a lot of Challenges in this and i solved them , but am still having a Problem,. Let me explain what i did So Far.
Step1:
I Prepared a a DeepZoom Project and it Created a Solution that has two Projects, the other one has a Folder(ClientBin) that has DeepZoomProject.xap and the other one has "App.xaml" and some Class Files that take care of mouse movement Zooming in my Project i suppose.
Step2: I created a New Solution(ASP.NET Application) in Different Directory and after that went to File-> Add Existing Project->And Went to the Solution that was created by DeepZoom. So it added both the Projects that i have explained above. That means in my Solution now i have 3 Projects.
Step3: I built the Solution and i got the Following Errors
Error 1 Library project file cannot specify ApplicationDefinition element. DeepZoomProject
Error 2 The project file contains a property value that is not valid. DeepZoomProject
Error 3 Cannot update project reference 'DeepZoomProject'. Failed to create the directory ClientBin|false. Unable to add folder 'ClientBin|false' to the Web site. Cannot create folder 'ClientBin|false'. The filename, directory name, or volume label syntax is incorrect.
C:\...\DeepZoomProjectWeb\
Now this Errors Originates from the Project that is Carrying the App.xaml. The other Project says Succeded after i buid them.
I have not yet Embeded the "DeepZoomProject.xap" File in the ASP.NET Page.
Please Help me with the Next Step, amyo You meantion certain tabs Steps, but in VS2008
Go Silverlight Application tab, In the Project Properties there is no Silverlight Tab . Inn the StartOption in the Project Properties there is a Checkbox for Silverlight. i have chacked that.
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Many people have seen the flipping panel by Ian Griffiths as shown by Sacha Barber on this MyFriends sample on CP.
http://www.interact-sw.co.uk/iangblog/2007/05/17/wpf-flippable-3D-list
http://www.codeproject.com/KB/WPF/MyFriends.aspx
I try now to figure out, how to invoke the trigger to flip the page by a RoutedEvent, but I cannot get it there.
public void ShowBack()
{
DataTemplate _dt = (DataTemplate)this.FindResource("flipItemTemplate");
RaiseEvent(new RoutedEventArgs(FlipToBackEvent, _dt.VisualTree));
}
should call this one:
<DataTemplate x:Key="flipItemTemplate">
<Grid Width="270" Height="270">
<Viewport3D Grid.Column="0" x:Name="vp3D" Visibility="Hidden">
</Viewport3D>
<Border x:Name="frontWrapper">
<Border x:Name="frontHost" Background="Transparent">
<Border.Triggers>
<EventTrigger RoutedEvent="local:UserControl1.FlipToBackEvent">
<BeginStoryboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource frontTemplate}" />
</Border>
</Border>}
Does anyone know how I can invoke from Codebehind the Storyboard inside the Trigger, inside the DataTemplate?
Tips on this are welcome
Christoph
|
|
|
|
|
Christoph
Not sure what you are trying to do with the VisualTree as part of the FlipToBackEvent, but I would have thought you don't need to do that, and just raise the FlipToBackEvent event when you need to and them XAML Trigger will see that, and act accordingly.
This would seem right to me, but I just don't have the time right now to look further, sorry.
Sacha Barber
- Microsoft Visual C# MVP 2008
- Codeproject MVP 2008
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
|
Sacha
Just fire was my first attempt, and works for Triggers that are not inside a DataTemplate,
so I tried different things.. they all don't work
Thanks anyway
|
|
|
|
|
Ah ok, sorry to hear that. It sounded like that would work.
Sorry I don't have more time to look at this myself.
Sacha Barber
- Microsoft Visual C# MVP 2008
- Codeproject MVP 2008
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
|
Sacha -
found it finally (I rarely give up)
this one was hard for me, then I came to this
// http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/4a04938b-690b-4bd0-969a-6dc4f6d6fda5/
this.displayContent = ContentControl
foreach (Border _border in FindInVisualTree(this.displayContent, a => { return a is Border; }))
{
_border.RaiseEvent(new RoutedEventArgs(FlipToLoginEvent));
}
- Christoph
|
|
|
|
|
Cool, glad you are now sorted.
I would have maybe gone for the x:Key idea on that thread.
Sacha Barber
- Microsoft Visual C# MVP 2008
- Codeproject MVP 2008
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
|
you are right, not perfect though working
here I present my final solution (for the ones that search the internet desperately
private T GetObjectOfTypeInVisualTree<T>(DependencyObject dpob) where T : DependencyObject
{
int count = VisualTreeHelper.GetChildrenCount(dpob);
for (int i = 0; i < count; i++)
{
DependencyObject child = VisualTreeHelper.GetChild(dpob, i);
T childAsT = child as T;
if (childAsT != null)
{
return childAsT;
}
childAsT = GetObjectOfTypeInVisualTree<T>(child);
if (childAsT != null)
{
return childAsT;
}
}
return null;
}
private void ManualStartAnimation(string templateName, string elementName, RoutedEventArgs eventArgs)
{
DataTemplate _dt = (DataTemplate)this.FindResource(templateName);
if (_dt != null)
{
ContentPresenter _cp = GetObjectOfTypeInVisualTree<ContentPresenter>(this.displayContent);
if (_cp != null)
{
UIElement _element = (UIElement)_dt.FindName(elementName, _cp);
if (_element != null)
{
_element.RaiseEvent(eventArgs);
}
}
}
}
public void ShowLogin()
{
->kick ManualStartAnimation("flipItemTemplate", "frontHost", new RoutedEventArgs(FlipToLoginEvent));
}
|
|
|
|
|
THANK YOU! I so did desperately search the internet and I found your nice solution. Thanks again!
modified on Friday, January 9, 2009 3:19 PM
|
|
|
|
|
Hi!
Can anybody confirm there is a memoryleak by using Brushes this way?
private SolidColorBrush[] colors = new SolidColorBrush[] { Brushes.Green, Brushes.Red, Brushes.Yellow };
private void DoEverySecond(bool status)
{
this.Background = status == true ? colors[0] : colors[1];
}
If so, how can it be avoided?
Explanation:
I have a timer which checks the status every second. Therefore I use the dispatcher to invoke my control.
If I do it this way my application grows up to 2.7 GB RAM usage within 12 hours.
I think I located the problem to the Brushes, although I'm not certain. If this is the reason, could anyone be so kind to give me an example to avoid this?
Thanks in advance,
eza
|
|
|
|
|
Why are you doing this? I can see why you want to check something every second, but wouldn't you be better using data binding and a trigger to perform this? You want to change the background colour when the status changes - which is a perfect candidate for a datatrigger.
|
|
|
|