I am trying to convert a MonoTouch.CoreMedia.CMTime variable in seconds. In native code, the solution is simple:
CMTime duration = ...
double durationinSeconds = CMTimeGetSeconds(playerDuration);
But I am not able to find the same method CMTimeGetSeconds in the MonoTouch API. Somebody can help me?
Thanks in advance!
It looks like this method isn't bound (nor any of the other CMTime methods). I will look into fixing this.
In the meantime it should be easy to calculate yourself:
double durationInSeconds = (double) playerDuration.value / (double) playerDuration.timescale;
The actual function also takes care of invalid/indefinite/infinite time values, depending on your need you'll have to take that into account too.
Now it will be simply:
CoreMedia.CMTime duration = ...
duration.Seconds;
Add CoreMedia.framework to project
Related
Sometimes I have difficulty in understanding the logic behind JavaScript and this is one example of something I often see. Here is a simple function that will be passed to a timer:
function myCounter() {
//do something...
}
You can just pass it like this:
setInterval(myCounter, 1000);
But, often we need to have the means to stop it so we assign it to a variable:
var t = setInterval(myCounter, 1000);
This allows it to be cleared later like this:
clearInterval(t);
I use this all the time but it bothers me that I don't understand exactly what I am putting into the variable, and why typeof t returns a number. What exactly have I put in t? Can anyone explain the logic behind this?
When you assign an interval to a variable, you are actually assigning an ID. That ID is then used when you use clearInterval to select which timer to clear. The reason typeof returns a number, is because an ID is a number.
Here is a detailed explanation.
MDN is a fantastic resource for this sort of thing, I highly recommend it
Sorry if I had this stupid question...I've been trying to google for answer but couldn't find one. :(
I have a problem assigning a variable to a virtual interface. For example:
Param.sv
...
string MyInput[3];
MyInput[0] = Signal_CLK; //Storing SignalName to in an Array.
MyInput[1] = Signal_Tx;
MyInput[2] = Signal_Rx;
...
MyInterface.sv
...
Signal_CLK = dut.MicroController.Source.clk; //Signal destination
Signal_Tx = dut.MicroController.Tx_01;
Signal_Rx = dut.MicroController.Rx_01;
...
Test.sv
virtual MyInterface my_vif
logic [7:0] read_value;
....
for (i = 0; i <3; i++ )
begin
read_value = my_vif.My_Input[i];
..
//some logic to compare read_value with spec//
..
end
The problem is when compiling, it doesn't translate my_vif.My_Input[0] into my_vif.***dut.MicroController.Source.clk***. Instead, it thinks that the path is my_vif.***My_Input[i]***.
The reason the compiler thinks you are trying to access my_vif.My_Input[i] is because you are. The My_Input[] array is a completely separate string array; not part of the virtual interface. When using the "thing.thing.thing" syntax, the compiler will loyally follow it, so it will expect there to be something called My_Input that has some elements (as its an array) as a member of the interface given by my_vif.
However, looking over youre code, you are trying to have My_Input[i] replaced at compile time, which is very different. The compiler will not run your loop, look in My_Input[i] and find the string "Signal_CLK" and replace that as part of the path to get the path my_vif.Signal_CLK. Nor can it do that at run time.
I dont know of a generic solution to looking over any variables in an interface; though Im also not sure if thats really what you want. IF you provide more details on the rest of your checker, we might be able to help you more.
You cannot use strings to look up identifiers by name within SystemVerilog. There are tool specific and C interfaces that may let you do this, but that would be very inefficient. The best way to do this by using a combination of abstract/concrete classes and the bind construct. See these references: http://events.dvcon.org/2012/proceedings/papers/01P_3.pdf and http://www.doulos.com/knowhow/sysverilog/DVCon08/DVCon08_SysVlog.php
So I'm using the OpenMesh library for a project and I'm passed in an EdgeHandle e to a method. Is it possible to see what two faces are joined by this edge? I tried looking online but the documentation for openMesh is very sparse and the stuff for EdgeHandle is even sparser.
Yeah, the OpenMesh "documentation" is pretty aggravating. However, from searching for the face_handle mentioned by tintin, I found this page hidden in it which gives a large number of useful functions:
http://openmesh.org/Documentation/OpenMesh-2.4-Documentation/classOpenMesh_1_1Concepts_1_1KernelT.html
Using the stuff found there, the following works for me:
FaceHandle a = mesh.face_handle(mesh.halfedge_handle(e,0));
FaceHandle b = mesh.face_handle(mesh.halfedge_handle(e,1));
(Technically, I enclosed the right hand sides in a function call, so I haven't tried this exactly as written. The right-hand sides should return some form of FaceHandle, at least.)
It's not hard to deal with this,
HalfedgeHandle halfedge_handle(VertexHandle _vh) const {
return vertex(_vh).halfedge_handle_;
}
using this function, you will be able to generate a half edge handle with the edge_handle. and you can
mymesh.face_handle(_hh);
mesh.face_handle(mesh.opposite_halfedge_handle(_hh));
to get the two face_handle you need.
Does anyone know what's wrong with the code below? The this->progressBar1->Value part worked by the button_click_event but not in this snippet. I've been messing around with it but to no avail:
int Trouble ()
{
int hour = System::DateTime::Now.Hour;
this->progressBar1->Value = hour;
return 0;
}
This code snippet is part of a WinForm and it is located in the #pragma endregion part of my code (BTW This is Visual C++). As always I will apperciate any help or suggestions. Thanks!
It appears you've made this a free function rather than a member function of your class. Place this definition inside your class' definition (probably under the private: access modifier) and you'll get the behavior you expect. Also, do some reading on "scope", as it's a very fundamental concept and not understanding it is why you're having this problem.
I think this exchange of comments may qualify as an answer:
#Francis: Then you'll need to show more code, especially the function which calls Trouble. – Ben Voigt
There's no function that calls it; this code is stand-alone. – Francis Lau
So you can remove it from your code, and the program still compiles? – Ben Voigt
You may say that. – Francis Lau
That certainly explains why it doesn't "work". It's not sufficient to write a function, you also have to call it at an appropriate time.
I recently got started on Core Data, thanks to this tutorial :
http://www.techotopia.com/index.php/An_iPhone_OS_Core_Data_Tutorial
My question is about handling types other than String.
For example let us say I want to add to the existing fields (name,address and phone : which are all String(s) in the example presented), the weight which I want to be a float in my entity.
How would I change the code to handle a float instead of a String ?
I already tried to change one of the fields to float in my entity. First letting the code as it is, and the program crashed. Then I tried to adjust the code in some ways but it did not work. I have the feeling it must be simple, but I can't get it right.
Thanks for any tip.
you should use NSNumber for float (and access it with [myNumber floatValue]).
You can't use primitive values in CoreData entities - only objects. ( NSString, NSDate, NSNumber, NSData ... )
Hope this helps.