My simple question is how do I get the 'position' value and how do I have a function when it changes?
https://pub.dev/packages/chewie
_chewieController.videoPlayerController.position;
Knowing that position is a Future(Duration).
Thanks in advance...
Try this:
Duration time;
_chewieController.videoPlayerController.position.then(
(result){
time = result;
}
);
Related
I am working with video/audio stream and using AudioQueueRef to play audio. I use current time of AudioQueueRef for synchronizing video/ audio frame in real-time. When i seek to the specified time, the current time of AudioQueueRef i got is not return the correct value, it just returned continuously value with before of timing. I think the problem is i did not reset all old object of AudioQueueRef. But i tried many of method and i did not get the expectation current time value. Anyone has idea for this case? Thank in advanced.
Method i get current time of AudioQueueRef
- (double)currentTime {
double timeInterval = 0;
AudioTimeStamp timeStamp;
AudioQueueGetCurrentTime(_AudioQueues, NULL, &timeStamp, NULL);
timeInterval = 1000 * timeStamp.mSampleTime / self.inFormat.mSampleRate; // convert to miliseconds
return timeInterval;
}
And methods that i tried to reset value when seek. If i use any method below, the current time will return negative value.
AudioQueueFreeBuffer(_AudioQueues, _AudioBuffer);
AudioQueueFlush(_AudioQueues);
AudioQueueReset(_AudioQueues);
P/S: all things is correct before seeking, after seeking, the timestamp is return continuously value.
I am using a Map control in my app, and i need to set the visible region in such a way that it should cover all the pins.
Irony is same code doesn't work on both the platform, iOS works awkwardly , below code yield almost the same visible region in both platform.
if(Device.OS == TargetPlatform.iOS)
customMap.MoveToRegion (MapSpan.FromCenterAndRadius (customMap.CustomPins [0].Pin.Position, Distance.FromMiles (0.20)));
if(Device.OS == TargetPlatform.Android)
customMap.MoveToRegion (MapSpan.FromCenterAndRadius (customMap.CustomPins [0].Pin.Position, Distance.FromMiles (55.0)));
Can anyone explains it? why I need to code like it?
i have found a workaround , i am waiting for some explanation before accepting my own answer for it
Device.StartTimer(TimeSpan.FromMilliseconds(500), () =>
{
customMap.MoveToRegion(MapSpan.FromCenterAndRadius(customMap.CustomPins [0].Pin.Position, Distance.FromMiles(55.0)));
return false;
});
I was running into a problem where the MovetoRegion was being delayed (15-30 seconds) when trying to center on the users current location using the Xamarin Geolocator Plugin, on both IOS and Android. Things work alot better with Saket Kumar's approach with the 500ms delay. Here is my code snippet, hope this helps someone.
private void CenterOnMe_Clicked(object sender, EventArgs e)
{
var locator = CrossGeolocator.Current;
var t = Task.Run(async () =>
{
var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10));
Device.StartTimer(TimeSpan.FromMilliseconds(500), () =>
{
AroundMeMap.MoveToRegion(
MapSpan.FromCenterAndRadius(
new Position(position.Latitude, position.Longitude), Distance.FromMiles(1)));
return false;
});
});
}
I'm fresh to iOS Programming, I'm trying my first test as a very simple game , so in this game I want to repeat a function every time the object reach y=80.
The problem in my code that the objects disappear and regenerate from the beginning ,so how can I repeat it?
-(void) TreeMoving{
Tree1.center=CGPointMake(Tree1.center.x, Tree1.center.y+1);
Tree2.center=CGPointMake(Tree2.center.x, Tree2.center.y+1);
Tree3.center=CGPointMake(Tree3.center.x, Tree3.center.y+1);
if (Tree1.center.y>590) {
[self PlaceTrees];
}
you can use the modulo ( % ) operator.
Try this :
if (Tree1.center.y % 80 == 0)
{
[self PlaceTrees];
}
I'm trying to create a swipe function to work in iOS devices. I've calculated the start touch position and the end touch position. Now, I want to calculate the start time and end time to get a time difference between the two touch events.
I've tried Time.time and Time.deltatime but as You already know It didn't work. So Please Help. Or if have any better suggestions for swipe, then please suggest me.
Thank You.
I believe what brandon is implying is you need to record Time.time in a variable such as startTime where you detect start touch then where you are recording the end touch do something like:
diffTime = Time.time - startTime
EDIT: Based on your comment I'm assuming it didn't work. Without your code its hard to say where you're getting lost but I'll try a psuedo code example in C# (don't know whether you're using Boo, C#, or Javascript):
public class Example : MonoBehaviour {
public float startTime;
public float diffTime;
void Update() {
if (/* DETECT TOUCH START */ ) {
startTime = Time.time; // Record startTime in secs since game start.
}
if (/* DETECT TOUCH END */ ) {
diffTime = Time.time - startTime; // Record diffTime in secs since startTime.
Debug.Log("startTime / diffTime = " + startTime + " / " + diffTime);
startTime = 0; // Reset startTime.
}
}
}
I'm having a very difficult time trying to get my data to be grouped via month. I've even gone so far as to programmatically filter through my data to return only the last day of the month and calculate the monthly value. I've tried to find a good explanation on the 'dataGrouping' property but have had no luck understanding it nor properly implementing it. Every results returns my series in a daily interval.
My questions are as follows:
Is there a minimum number of data points needed for data grouping to
work?
Under the dataGrouping.units I've tried to use this
documentation but nothing has worked for me - Still results in a
daily interval - Could someone explain this for me?
Any help on this would be GREATLY appreciated.
Are you using HighStock graph?
If yes...
Sure, it takes a lot of data to get grouping. If datagrouping option is enabled, Highstock handle automatically the switch between every grouping mode. So if you don't have a lot of data, it will not work with default settings
So, if you want to group by default, you need to force the grouping.
series:[{
[...]
dataGrouping: {
approximation: "sum",
enabled: true,
forced: true,
units: [['month',[1]]]
}
}]
EDIT
Here is a working example demo (fork of a basic highstock demo)
http://jsfiddle.net/NcNvu/
Hope it helps!
Regards
We tried a Hack around this, where we used Highstock's (Splinechart) RangeSelector, Event and DataGrouping. On click of weekly rangeselectorButton we catch this event through setExtremes. Post catching the event approximate it to "sum". If you are using two series than iterate the object. Currently doing it weekly just extend it for Monthly using corresponding UNIT
events: {
setExtremes: function (e) {
if (e.rangeSelectorButton != undefined) {
var triger = e.rangeSelectorButton;
if (triger.type == 'week') {
$.each(this.series, function (index, obj) {
obj.options.dataGrouping.units[0] = ['week', [1]];
});
} else if (triger.type == 'day') {
$.each(this.series, function (index, obj) {
obj.options.dataGrouping.units[0] = ['day', [1]];
});
}
}
}
},