-
-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pygame.music.Music
implementation
#3108
Comments
Yes. Most important detailI think this object should be contained in the
Relevant details
|
I wrote |
I specified the alias should in fact be of |
No, it's not the goal. All functions available right now will still update the music object and do what they do. Also I forgot to talk about a really useful function which I'll add to the original message. |
I don't understand, why would someone use mixer_music if this object exists? apart from volume, this looks complete to me. and I think get/set volume should reside in pygame.music I don't understand another thing, pygame.music would not be an alias, it would be a new module. unless we have different ideas. |
My thoughts and observations on the modules (note I haven't really used mixer or music modules in my projects yet): Nowhere in the docs is the " The current implementation where import pygame.mixer.music # ModuleNotFoundError
from pygame.mixer.music import play # ModuleNotFoundError This same problem may occur if you do an alias variable Three options for music module:
In any case, I agree that |
Opinions about implementation:
|
Good question,
I don't support this idea for now, as we can't play 2 musics at the same time. It wouldn't make sense in my opinion to have a local and a global volume.
When a music is loaded using a path like before, if you call this function, it's supposed to build you a music object and return it to you. This allows you to edit the music when you don't have access to it in a certain part of your code.
I agree. |
@aatle @bilhox important question to both, why would end event be raised when you stop the music manually? what is the benefit? what if I want my endevent code only to run when it ends gracefully? I don't like "stopped" as an event attribute, it's unintuitive and ugly api-wise in my opinion. what other parts of pygame raise events on manual operation, to justify this? |
This is because with |
This is the behaviour of |
|
If this is how ENDEVENT works, then I can understand it, for the sake of consistency. thanks for letting me know! |
While you're mentionning it, IMO I would not, for the sake of maintainability, create a system for the less than 0.5% users using SDL mixer with a version lower than 2.6.0. (You can check the code behind the current implementation, it's a bit terrible) It's not like people are supposed to have this version now, especially when the recent versions of pygame use SDL Mixer 2.8.0 since a pretty long time. |
Hmm, if I understand correctly,
I still disagree with the
Though, the same can be said for if |
Regarding volume, this property will still be useful even when only one music can be played at a time. However, the global and local volumes would indeed have to be synced, so perhaps it could be a class property instead, the balanced middle ground. Unfortunately, there may be implementation problems here. Note: currently, a rounding issue with |
@aatle playing, paused, position, volume would all be properties (some read only) as they use sdl under the hood hold on, why class property? instance property! |
I meant a property that just delegates to global volume, all Music object's volume would be the same. |
what's the utility of that? mixer music volume already exists. it makes more sense as an instance property |
What I mean is an instance property that is always the global volume, to mitigate any problems with having both local and global volumes. |
As currently, pausing / stopping is done for any playblack, I would like to remove temporarly I'll be taking in account the suggestion for EDIT: same for |
Shouldn't the pause, stop, and rewind functionality be available in the Note: |
I found a solution for the problems above, therefore, I think when a new music is playing while another ( Also, I noticed that we can add effects on the music stream using the callback function used by the old system to increment the position. Might be interesting to play with it if you have any famous effects in your mind. |
Updates about the implementation:
|
2 questions:
|
What setters ?
I use |
of course, the position setter! |
Ah this one, yes I'm curently reimplementing it as I found a solution for it as well. |
So, can you give a summary of all of the properties and methods, and which may raise |
It'll not raise an error, the user didn't make a mistake so it doesn't make sense. Therefore, they will get |
Okay. What about property setters though? Are they guaranteed to work? |
Hello everyone,
As discussed on discord and on #3058 , I want to introduce a new pygame object that will help users to manipulate their musics in a better way, and also in a more pythonic way.
The goal of this issue to collect feedbacks on how it should be implemented before opening a PR for its implementation.
Implementation
pygame.Music
is an alias ofpygame.music.Music
.pygame.music
should be an alias forpygame.mixer_music
.path
is not necessary astr
but support all types that pygame supported before.I don't like how
pygame.mixer.music.set|get_endevent
works, it's not something the user have to setup. This is why I propose a better way IMO, whenMusic.stop()
orpygame.mixer.music.stop()
is called, or when the music ended peacefully, apygame.MUSICENDED
is sent to the event queue. This event would have a single attribute,music
which is the music object that ended.I highly support the metadata attributes than an actual
metadata
dict attribute, imo it doesn't look cool to write. Btw, what about an attribute for the music format type (ogg
,wav
,mp3
...) ?Why the need of this feature ?
For many reasons :
pygame.mixer.music.set_pos
worked on the old implementation, which was definitly wrong. Also bring a homogeneous measure system (before get_pos was returning the value in ms, and set_pos needed a value in seconds).So we can forget the cursed code we can see inmusic.c
Updates
Music.is_playing
got renamed toMusic.playing
MUSICENDED
event could have astopped
attribute so the user can now if the music got brutally stopped by a hater or not.The text was updated successfully, but these errors were encountered: