custom seekbar/scrubber on a media player UWP - multithreading

So I'm coding a music player and don't want to use their defualt mediaplayer control panel.
I have a slider object (SeekBar) and I know I can update it to display the postion i am in a current song as such:
SeekBar.Value = (int)PlayMusic.Position.TotalMilliseconds;
So when I call the above the bar move to the exact position I need it to be
So how can I start a thread (async method?) that calls a function that loops the above every millisecond. I'm pretty new and have been trying this for a while.

Related

How to make player restrict of boundries in phaser js game?

my code is here ( https://www.codepile.net/pile/7mPpA9m0 ) the player is go out of box of canvans how to make it restrict
Just call the method setCollideWorldBounds on the players physics object, than the player should not be able to leave, teh Zone.
In the create function just add this line of code: this.player.body.setCollideWorldBounds(true);

Which is Right Way to Add Joystick in Unity3d , Adding on Scene Directly or Iniatiating it From Player Scripts

I have to add Joystick control in my Game
I had done with Two Approaches both works well for me , but confused Which one to go with.
1) Initiating Joystick Control from Players Object/Script and getting inputs there.
2) Add Joystick Control Directly to Game Scene and then accessing it in player script by findObjectwithTag and getting inputs .
Calling "Instantiate" and "GameObject.Find" is pretty expensive so in my opinion the efficient way is
1: Add Joystick Control Directly to Game Scene
2: Create a public object inside player and assign "joystick control" from inspector (Editor).

is there a way to keep updating GL contents with paintGL in QT?

I'm writing a video player with two QGLWidgets -- a controller(a menu with buttons like select, play) and a viewer(where the video actually gets played). For the viewer, I have the paintGL function calling the display function I implemented to update each frame. But unless I resize the viewer window or switch between the two windows, the viewer doesn't update itself and just stops on the third frame.
In other post, I found that I have very little control over when paintGL gets called (resizing is one of the cases where it gets called). Is there a way to work around the this?
Thanks!
Edited:
So I have two classes: Player and Viewer (both QGLWidgets)
When running the program, a player (the controller) will be displayed, and users can choose a video and hit the play button. The player handles the play button in the way that it creates a Viewer which plays the selected video.
def handlePlayButton(self):
self.viewer = Viewer(self.filepath)
self.viewer.show()
And the Viewer is initialized and updated as following
def paintGL(self):
self.display() //update the window with the current frame
glViewport(0, 0, self.vid.getWidth(), self.vid.getHeight())
def resizeGL(self, w, h):
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
def initializeGL(self):
//initialize the shaders with other libraries

Spotify: Linking tracks on page

How can I link different tracks present in a particular tab on spotify page, so that when clicked on spotify next/previous button the next/previous track is played. Presenlty it is not playing anything if clicked on next button, when it should be starting to play the next track present on the page
My script looks like this,
$.each(allTracks,function(index,track){
models.Track.fromURI(track, function(track) {
models.Album.fromURI(track.album.uri, function(album) {
var single_track = models.Track.fromURI(track.uri);
var single_track_playlist = new models.Playlist();
single_track_playlist.add(single_track);
var pl = new views.Player();
pl.context = single_track_playlist;
if(index==0) {
$("#firstTrack").append(pl.node);
}
.............
.............
Can anyone please guide me on how I should be going around doing this? Thank you in advance
In your case, the context of each Player view is a playlist with that single track. If you want to render your tracks as players, and have them synchronized so that the next track plays after the one before ends, you need to create a custom solution.
You can check this Grid Play Spotify App, that shows an example of how to achieve it. It basically creates custom Player views that respond to certain events triggered by the Player model and other Player views.

Spotify API: Playing a specific part of a song

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

Resources