I'm trying to play a song from a position other than the beginning of the track.
I've found that player.position = X will work as a standalone function, such as triggered by a button, but triggering it on player.observe(models.EVENT.CHANGE... results in a crash.
I figure this is because the track hasn't actually started playing once the event occurs as the player.position may still be at the previous song's position.
I've also experimented with sp.trackPlayer.seek() which seems to give the same results.
So has anyone got a song to start playing at another position than 0? (Or made the playhead jump ahead after the event of playing a new song?)
Add the position after the uri, for example:
var uri= 'spotify:track:xxxxxx#02:04'
player.playTrackFromUri(uri)
See this sourcecode if you want inspiration:
https://github.com/Iteam1337/Wejay/blob/master/javascript/room.js
Related
Here is my code: (just so you know I am a beginner and I just started this week, though I do have knowledge with other languages and game engines)
func _on_Area2D_area_entered(area):
get_parent().get_node("Level 1/Area2D/Flag").rotation_degrees += 1
What I was trying to accomplish was that the Player GameObject would see if its in the area of the Flag, and if it is, the flag would rotate.
I am not sure where the issue is. I think it is probably in the second line. I provided a screenshot below if I did the setup wrong. I have looked at the other close questions asked on the same topic, but they did not answer my question.
The "Player" GameObject is the one with the script that contains the detection if its in the area2D.
If you want to check if the Area2D is positioned correctly during runtime enable Debug -> Visible Collision Shapes.
If you want to check if _on_Area2D_area_entered is running, add breakpoints (or use print).
Did you get an error?
If there isn't a Node there, this expression will cause an error in runtime:
get_parent().get_node("Level 1/Area2D/Flag")
If you want to be able to check, you can use get_node_or_null and is_instance_valid.
Since you didn't mention any error, I'm going to guess the method is not running.
If the method is not running, the most likely culprit is that - I'm guessing given then name of the method - you connected the "area_entered" signal but intended to connect the "body_entered" signal.
The "area_entered" signal will trigger when another Area2D enters the Area2D. But I only see one Area2D in your scene tree. On the other hand the "body_entered" will trigger when a PhysicsBody2D (e.g StaticBody2D, KinematicBody2D, RigidBody2D) enters the Area2D. In either case you get what entered as a parameter of the method.
Other reasons why the Area2D might not be detecting what you want include no intersection of collision_layer and collision_mask and monitoring being disabled.
And to dismiss a couple possible misconceptions:
The "area_entered" and "body_entered" trigger when the Area2D or PhysicsBody2D respectively enter the Area2D, not every frame they are inside. So rotation_degrees += 1 is not a rotation animation.
You will get notifications of anything that trigger the signals, not just the object to which you connected it. You may have to further filter, e.g. if body == self:.
For people arriving here from search, I want to link a similar case: Enemy is not affected by bullets. And also my full explanation of how to set up physic nodes.
I am very new to Unity / Vuforia scripting and really need help.
I have composed a whole Timeline in unity but cannot trigger an event ... there are still code errors ...
In the DefaultTrackableEventHandler script, I understand that you have to attach a piece of code that allows these events to be triggered but I haven't been able to do this for 48 hours. Help from the community would be very useful. please.
Here is the scenario:
When launching the application a video should appear. When the target is found, the video should stop to leave room for the Timeline which is triggered automatically, since the target has been found. If the user loses the target then the Timeleine will have to stop and the starting video will have to start again.
Someone could help me with this problem that has taken my head for 48 hours ...
thank you so much
Looks like you have to write scripts that contains differents functions that manage all those points. One script that starts and stops your video (2 different functions), and a other that starts and stops your timeline. (Don't forget to hide the video when you stop it)
Once you have those scripts you can attach them to a object and then, use them in DefaultTrackableEventHandler. (You add you function to the right event by clicking the + button, dragging your object with the script and choosing the right function to use).
Screenshot of DefaultTrackableEventHandler
In my project I am attempting to play a music track when the screen switches to the game over screen. It starts when it is supposed to, however, the track continuously loops even when looping is set to false. I tried also using the OnCompletionListener, However I either set it up incorrectly or It just didnt work for some reason or another
This is the variable in my create method.
music = Gdx.audio.newMusic(Gdx.files.internal("gameover.mp3"));
This is the track set up in the render method
music.setVolume(.2f);
music.setLooping(false);
music.play();
The problem seems to be you're calling play() in the render() method, try calling it on the show() method or use a boolean to flag that you're already playing the music and don't play it again.
Sorry if it looks like a noob question, but i'm new to titanium so some concepts are foreign to me.
I have a script called entry.js which is called from details.js using require('entry.js').
Now within entry.js i play a sound, depending on what entry is selected.
var player = Ti.Media.createSound({url:"/sounds/0"+e.id+".mp3"});
player.play();
That part is ok. The problem is when i go back to the details screen, and select another entry, the new sound overlaps the old one.
So i need a global value or object that i can pass down to entry.js to make sure if the sound is playing or not.
But if i declare a global TI.Media object in details.js i get an error in entry.js:
Cant find variable player
So the question is, how do i detect in a sub javascript file that an instance of audio is already running?
You can check whether the audio is playing using the isPlaying() method or try to stop the playing music when you get back to the details screen. You can use stop() method to stop the sound. It will stops playing the audio and resets the playback position to the beginning of the clip.
If you want to create a global variable or pass variable from one window to another, refer the following links
Passing parameters from currentWindow to the new window in Titanium
Passing variable between windows
I'm new to GPUImage, but I think that it is really nice: good work Brad. I love the way the filters chain together so cleanly.
GOAL
I'm trying to wire up the following:
* create an openGL scene
* apply some filters (irrelevant to the discussion below)
* record to video
PROBLEM
My problem is I'm not clear how to connect up the recording. Unfortunately, interacting with opengl-es does not give me enough detail to work out what to do.
ATTEMPT
I have two starting points from the examples in the package:
* CubeExample - getting raw openGL to interact with GPUImage
* SimpleVideoFileFilter - recoding a video file through filters to a new file
I started with the CubeExample, substituted the videoCamera filter for GPUImageSolidColorGenerator (as an aside, I'm not sure how to start with no filter). This allowed me to be able to create a mesh, render it and interact with it. Then I thought that I'd simply add on a GPUImageMovieWriter filter as per the instructions given in filtering and re-encoding a movie, but that requires coordination between the GPUImageMovie (the source) and the writer. As I'm not wanting a camera stream or a video file as the source, but an animated openGL sequence, I'm not clear how to do it. I've tried adding a videoInputReadCallback to the movieWriter:
movieWriter.videoInputReadyCallback = ^{
[renderer nextFrame];
[movieWriter newFrameReadyAtTime:renderer.cmTime atIndex:0];
};
where nextFrame is creates the next frame, calls endProcessing when done and sets the CMTime. Without the newFrameReadyAtTime:atIndex: call, it works fine (animated image rendered as expected to the screen) except that it creates a video with only one frame in it. With the newFrameReadyAtTime:atIndex: call, I get the message
Problem appending pixel buffer at time: 6
before it dies, which makes me think that the movieWriter is not yet ready for the renderer to present its frame, but I'm not sure what to do about it. I've tried many other things, but to no avail. From the description in Interacting with OpenGL-ES (see link above), it seems like it should be easy, but I'm not having any luck.
REQUEST
To make the question more relevant to others, I would just like it if someone might be able to post an example of creating an openGL scene (eg a triangle) and connecting it to GPUImageMovieWriter to record to a file, perhaps rotating the triangle for 10 frames so that we can see that more than a still image is created.
thanks.