new user to c4iOS framework. Working my way thru the tutorials/examples - wondering how one goes about playing back audio (as opposed to video, which is covered in the example texts).
thanks in advance for answering my less-than-advance 'n00b' question
-jf
Audio samples are fairly similar to movie objects, albeit they don't have an option like shouldAutoplay that will get them running as soon as the application loads.
The easiest way to construct a sample is like this:
#implementation C4WorkSpace {
C4Sample *audioSample;
}
-(void)setup {
audioSample = [C4Sample sampleNamed:#"C4Loop.aif"];
}
Which builds the audio sample object as a variable that you can then reference in other methods. For instance, if you want to play a sound clip when you first touch the screen you would do the following:
-(void)touchesBegan {
[audioSample play];
}
To toggle the playback for each touch, you would do something like:
-(void)touchesBegan {
if(audioSample.isPlaying) {
[audioSample stop];
} else {
[audioSample play];
}
}
A working copy of a C4 app that toggles playback can be found HERE.
There are also a lot of properties for audio samples that let you control things like playback rate, volume, panning and so on.
An example of changing the volume is like this:
audioSample.volume = 0.5; //0 = mute, 1 = full volume
An example of skipping to a specific time in a sample would be like:
audioSample.currentTime = 1.0f; //this will put the "playhead" to 1.0 second
You can have a look at the C4Sample documentation to see more properties and other aspects of the class. The documentation is also available via the Xcode organizer.
Related
What I want is that on a-frame, when I talk, my 3D model avatar is also being made talking.
Following this guide, https://aframe.io/docs/1.1.0/introduction/models.html#animating-models, I created 3D model avatar with this resource, https://sketchfab.com/3d-models/bake-talking3-e715ab67be934a108d0a952d90c07210
But this gltf 3D model is talking all the time. I need interactive 3D model talking whenever I talk.
Let's assume my voice detection is already implemented.
Can anyone answer this, please?
The animation-mixer component has two methods that should help
playAction() which will play the
stopAction() which will stop the
Let's assume my voice detection is already implemented.
Then Your code could look like this:
const modelEntity = document.querySelector("[gltf-model]")
const animationComponent = modelEntity.components["animation-mixer"]
mySpeechRecognition.onspeechstart = function() {
animationComponent.playAction();
}
mySpeechRecognition.onspeechend= function() {
animationComponent.stopAction();
}
Something like what I did in this glitch. Green plays, red stops. Click on the fish to check out the source.
I need an algorithm to tell a sprite to end as soon as the text finishes appearing, basically I need to make a cutscene which describes the beginning of a story within the game, but since I'm using gamemaker, I don't know how to do it, can someone help me?
For cutscenes and automated image sequences you usually have some sort of variables, that handle the states and counters for displaying sprite's sub-images.
But firstly I like to use mainly two main time-related variables in my controller object usually named sys (counter and counterTime):
c = 0; // and for stepEvent: c += 1; // so it goes +1 per step
ct = 0; // and for stepEvent: ct+= 1 / room_speed; // so it goes +1 per second
During the cutscene you might want to stop everything else that moves:
is_cutscene = false; // objects might not be able to move when this is true
// you still have to implement that by yourself
// player can't move if is_cutscene, nothing happens!!
(except cutscene buttons etc...)
So now when the player gets to a 'cutscene'y object and triggers some cutscene_1 = true eg. you can have the image/text/sound/animation object come to life/create/active... That object might have in the create event:
duration = 6; // 6 seconds the scene lasts
start_time = sys.ct // and in Step: if sys.ct > (start_time + duration)
// then -> cutscene advance/destroy
Ofcourse - this is super simple and now you could only say implement:
walk close to a pop-up object
show an image for 6 seconds
it dissappears
And it might not be big trouble to implement it... BUT THIS may also be the foundation for more advanced multi-step sequence and cuts.
I can find no explanation on what these are actually supposed to do.
There are examples on:
https://jxbrowser.support.teamdev.com/support/solutions/articles/9000102480-forwarding-mouse-events
but 629 and 373 ? I can't figure out what those values are for. I can get the same behaviour with any value for those.
What if you one also sets windowX and windowY ?
What would they do to the result click?
I am looking to be able to click and move on a google map. Is that possible?
The x and y values define the mouse event coordinate inside the browser content area.
The globalX and globalY values define the screen coordinate of the mouse event.
The windowX and windowY are deprecated. If you set them, this doesn't affect anything.
For more detailed information about working with Google Maps, please take a look at the article.
Your browserView must be active/focused first!
Then, let's do this way:
public static void simulateMouseClickOnElement(Browser browser, BrowserView browserView, DOMElement element){
Rectangle rect = element.getBoundingClientRect();
Point ptOnScreen = new Point(rect.x , rect.y );
SwingUtilities.convertPointToScreen(ptOnScreen, browserView);
forwardMouseClickEvent(browser,MouseButtonType.PRIMARY,rect.x,rect.y, ptOnScreen.x, ptOnScreen.y);
}
JxBrowser is the BEST automation or crawling/hacking tool! Selenium is a best alternative choice due to the TCO.
I am trying to write a simple script using Zaber Console.
I basically have to move my robot arm to a certain position (i.e. 43.9mm) hold the position for 10 minutes and go back to the home position.
I found all the command for moving (fast/slow and with a certain acceleration) but I can't undestand how to tell the machine to stay at 43.9mm poistion for 10 minutes.
Any suggestions ?
I am coding in "this language":
if(PortFacade.Port.IsAsciiMode)
{
Conversation.Request("move abs", 881890);
Conversation.PollUntilIdle();
}
else
{
Conversation.Request(Command.MoveAbsolute, 881890);
}
Thanks a lot.
Riccardo
For your reference, if you are coding through the script editor in Zaber Console, we offer a scripting page which covers C#, Javascript, VP, as well as Python. You can find the scripting page here: http://www.zaber.com/wiki/Software/Zaber_Console/Scripting
The language in your script is using C#, and a quick program to execute what you'd like to do can be written like this:
#template(simple)
var device1 = PortFacade.GetConversation(1); // This is assuming your device
// is device 1 in the chain.
// The device list in Zaber Console will let you know the device number.
// Alternatively, you can use the renumber command to change the device number.
device1.Request("move abs 100000"); //the data value for 43.9 mm will vary
// from device to device. The formula would be 43.9[mm]/ Microstep size[mm] = Data value
// The microstep size can be found on the product page at www.Zaber.com, or
// email Contact#Zaber.com
Sleep(5000); //Sleep is in milliseconds
device1.Request("move abs 0");
If you have any questions, please don't hesitate to email Contact#Zaber.com.
Regards,
Albert
I'm writing a flex app, which must record an audio and then playback. It records just fine, I can hear the flv on the server, but when it comes to the playback it cuts the end a little bit, and each time I ask to reproduce again it cuts a little bit more. What can it be? I guess it's something related to buffer management, but I don't know exactly. Any thoughts?
EDIT: Here's the code I'm using to playback. It is called from a mediator:
var streamPlayClient:Object = new Object();
this.stream.client = streamPlayClient;
streamPlayClient.onPlayStatus = function(infoObject:Object):void {
if (infoObject.code == "NetStream.Buffer.Flush") {
stopPlayback();
}
}
this.stream.play("flv:" + this.streamName);
As it turns out, I have to handle the NetStream.Buffer.Empty event, instead of the NetStream.Play.Complete or the NetStream.Buffer.Flush.