|
By,
I want to know the lenght of audio file(like mp3 or Wav) in seconds.
What is the right way?
In the image file(like Jpg or Gif) i have used metadata with PropertyItem, there is a way like this?
Thanks.
|
|
|
|
|
Through DirectShow or WMP you can load an audio file and get it's length.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Excuseme,
It is possible to have an example?......an istance of the object and the dll to use.
Thanks.
|
|
|
|
|
I have the framework 1.1 and i can not know this data, you can help me please?
|
|
|
|
|
WAV files follow the RIFF standard that has a field that contains the length of data.
WAV files' headers has 3 chunks of data; RIFF chunk, FORMAT chunk and DATA chunk.
RIFF chunk: 12 bytes.
FORMAT chunk: 24 Bytes.
The DATA chunk format is as follows:
Bytes 0 - 3: 'data'
Bytes 4 - 7: Length of data.
You need length of data, sampling rate and number of bits per sample to get the duration
Extract Length of data from DATA chunk, and all other fields from the FORMAT chunk.
And done
لا إله إلا الله
|
|
|
|
|
How to populate the Bound the Treeview data into the datagrid.
Send me the sample for that
|
|
|
|
|
Sure, no problem. Whilst I am doing all your work for you, if you can think of anything else you might need, please let us know.
Regards
Malc
*********************************************
|
|
|
|
|
Is there any way to unsubscribe all event listeners for a certain event?
public delegate void myHandler(object Sender);
public event myHandler somethingChanged;
private void onSomethingChanged()
{
if(somethingChanged != null) somethingChanged(this);
}
What I would like to do is something like somethingChanged = null . Why isn't this allowed if I can actually check somethingChanged for null? somethingChanged -= someFunction is not an option, what I want is somethingChanged -= allListeners .
Can anyone help me out here?
|
|
|
|
|
Hi,
I don't know how to exactly do this but there should be a way.
I want to ask why do you want to do this ? because as far as I know your host doesn't know anything about its listeners.It's the responsibility of a listener to register or unregister itself.
Anyway how about having a flag variable that if set,it will stop the service.
For example:
<br />
public viod Stop()<br />
{<br />
stopped=true;<br />
}<br />
<br />
private void OnSomethingChanged()<br />
{<br />
if (stopped) return;<br />
}
|
|
|
|
|
Thx for the answer, wasn't expecting anyone to reply anymore. I've thought about that solution too, but I think there should be a more elegant way to fix the issue.
The reason I want to do this: the class concerned here contains some data that's shown and can be modified in dozens of places in my application. I've created a sort of "undo" function that saves a copy of the object to memory so that the user can "rollback" on his actions. These copies should contain only data, and shoudn't even try to fire any events. While debugging I found out that some references were left to my cloned objects, meaning the data in these clones is getting modified just as my "foreground" data. What's more, the number of cloned objects in memory could eventually be many thousands, so the performance hit for even for simply checking a flag each time isn't something I want.
Since manually disconnecting my eventlisteners is so sensitive to my own errors (code intensive) I'd like to be sure all eventlisteners get disconnected from the event. I'd expect the event itself to contain a list of references to all listeners. As I said before: How else could you check an event for null .
Suggestions are still welcome of course
|
|
|
|
|
Hi
This case can be an example of memento design pattern.Using this pattern you can save state of your objects in another object(a memento) and then you can put you object back to its initial state.
for example:
<br />
public class Test<br />
{<br />
private int x;<br />
public EventHandler XChanged;<br />
<br />
public int X<br />
{<br />
get{return x;}<br />
set<br />
{<br />
this.x=value;<br />
if(this.XChanged!=null) XChanged(this,EventArgs.Empty);<br />
}<br />
<br />
public TestMemento GetMemento()<br />
{<br />
TestMemento memento=new TestMemento();<br />
memento.AddField("x",this.x");<br />
}<br />
<br />
public void SetMemento(TestMemento memento)<br />
{<br />
this.x=(int)memento.GetField("x");<br />
}<br />
<br />
}<br />
and here is TestMemento
<br />
public class TestMemento<br />
{<br />
public void AddField(string key,object value)<br />
{<br />
this.fieldsMap.Add(key,value);
}<br />
public object GetField(string key)<br />
{<br />
return this.fieldsMap[key];<br />
}<br />
}<br />
this way you can save an object state and load it again.
Take a look at serialization patterns in C# and .Net framework.
Regards
|
|
|
|
|
Hi,
Thanks for the suggestion, someone has offered me the memento pattern before, and next time I'm implementing a feature like this I'll be sure to use it. Unfortunately I found out a bit late about this in order to use it for the current project: Should I want to convert my project to use this pattern would mean I'd have to change about 1500 base datatypes to start using it, I'm afraid I don't have the time or spirit to do so.
For now I found an ugly hack around the problem: I serialize the class and store it to a memorystream, then inmedialtely deserialize it and add it to my Collection of "undo" objects. Since the event is marked as non-serializable it gets initialized to null as soon as I deserialize it. It's a bit ugly and I still don't see why I can't just set event myEvent = null . But this performs quite well actually.
Cheers and thanks for the help!
-- modified at 10:10 Friday 25th August, 2006
|
|
|
|
|
Hi
Well serialization can be a good replacement for memento design pattern(except that you have to violate encapsulation somehow ,if you are using attributes)
I'm happy that you find a solution.
Regards
|
|
|
|
|
I am writing an application that acesses a SQL server, logging on with SQL server authentication and would like to set the menu option acording to the permission the logon user or group has, is there any way of interigating the SQL server for user permissions.
Any help would be appreciated and many thanks in advance
|
|
|
|
|
do you means this?
if login user is 'Admin', then he will get all records in a table.
if login user is 'User1', then only some of records in table return, but all.
|
|
|
|
|
Not so much in retrieving all records but to disable the logon from accessing certain tables. The program will have menu options to get different data from different tables and certain logons are not to have access to this information.
Thank you for your reply.
|
|
|
|
|
I have tryed in Sql Server 2005 Express version.
it have this feature.
see details here
-- modified at 22:37 Thursday 24th August, 2006
|
|
|
|
|
If I remember right you can read the system tables to do that but the best way would be to use the internall parameters (@@something). You should write your own function in SQL to do either. This is a question for an SQL forum because I am sure someone did this before and it is going to vary depending on SQL version.
|
|
|
|
|
Hi all!!
How do I convert the following to 1 line of code??
int intBottleQty = i * 6;
String strBottleQty = intBottleQty.ToString();
I tried String strBottleQty = i * 6; but it wouldn't convert. I always thought that integers can get converted to strings??
I hope someone can help me.
Regards,
ma se
|
|
|
|
|
try
string strBottleQty = (i * 6).ToString();
|
|
|
|
|
String strBottleQty = String.Format("{0}", i * 6)
|
|
|
|
|
try like this
int intBottleQty = i * 6;
String strBottleQty =Convert.ToString(intBottleQty);
i hope this will help u...
ayyp
|
|
|
|
|
ma se wrote: I always thought that integers can get converted to strings?
Yes, they can, but not automatically. You have to tell the compiler that you actually are wanting to do the conversion, and not just trying to assign an integer to a string variable by mistake.
Here are some of the ways that it can be done:
string bottleQuantity = (i * 6).ToString();<br />
string bottleQuantity = Convert.ToString(i * 6);<br />
string bottleQuantity = (i * 6).ToString(CultureInfo.InvariantCulture);<br />
string bottleQuantity = (i * 6).ToString(CultureInfo.CurrentCulture);<br />
string bottleQuantity = (i * 6).ToString(new CultureInfo("en-GB"));<br />
string bottleQuantity = (i * 6).ToString("0");<br />
string bottleQuantity = string.Format("{0}", i * 6);<br />
string bottleQuantity = string.Format("{0:0}", i * 6);<br />
string bottleQuantity = (i * 6).ToString("0", CultureInfo.InvariantCulture);<br />
string bottleQuantity = string.Format(CultureInfo.InvariantCulture, "{0}", i * 6);
---
b { font-weight: normal; }
|
|
|
|
|
Thanks, but if i are numbers ranging from 1 - 20, how can they be different in all the scenarios you have given me, I mean 1 is 1 and 2 is 2, etc.
|
|
|
|
|
What do you mean? Why would they be different?
---
b { font-weight: normal; }
|
|
|
|