2020-06-28 00:29:29

Hello. I have a file_stream object in sound lib that i can play audio with. But how do i seek in it? I am using carters sound class which i downloaded from americranians python tutorial and it doesn't offer this function but i am coding a small media player so it would be usefull if i could seek.

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2020-06-28 19:07:16

You want the position property on your sound_lib channel, self.handle.

pos = self.handle.position
# and to set later
self.handle.position = pos

Note that pos will be a number in bytes. This makes sense, since the duration as represented by time can change easily for a host of reasons.
In many instances though, it can be helpful to see the actual time. self.handle.bytes_to_seconds and self.handle.seconds_to_bytes does exactly what it sounds like.
HTH

2020-06-28 22:06:34

@2 thanks, for reference, i made it like this. This is what i wrote into sound.py.

@property
def position(self):
  return self.handle.position
@position.setter
def position(self,value):
  self.handle.position=value

And this is how i wrote it in my little program here.
  if pressed==pl.K_F3:
   s.position=s.position+s.handle.seconds_to_bytes(1)
  if pressed==pl.K_F4:
   s.position=s.position-s.handle.seconds_to_bytes(1)

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2020-06-28 22:13:24

cartertemm wrote:

You want the position property on your sound_lib channel, self.handle.

pos = self.handle.position
# and to set later
self.handle.position = pos

Note that pos will be a number in bytes. This makes sense, since the duration as represented by time can change easily for a host of reasons.
In many instances though, it can be helpful to see the actual time. self.handle.bytes_to_seconds and self.handle.seconds_to_bytes does exactly what it sounds like.
HTH


Vow. WHy no body told me about this before. i was searching for sommething like this in purpus of play back and forward mp3 files.

2020-06-28 22:36:11

@4
Because you asked for a wrapper for Windows Media Player, which is an entirely different thing.

My Blog
Twitter: @ajhicks1992

2020-06-28 22:56:01

@Simter, out of curiosity, do you ever write code in German? Or do you write it in English only? In fact, will the python inturprator accept German words? I also know you guys have a few extra letters as well, so that just popped in my head.

You ain't done nothin' if you ain't been cancelled
_____
I'm working on a playthrough series of the space 4X game Aurora4x. Find it here

2020-06-29 01:18:18

@jaidon, this media player is a german program. And yes, surprisingly it actually does. How eveer you have to use utf8 decoding.

Lamas with hats, but with sponge bob as carl Stay tuned.

https://www.youtube.com/channel/UCvAUQt … subscriber

2020-06-29 09:55:24

@5
i meant my previous topic about trying to build a music player. Thanks anyway.