-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Dynamically manipulating <source> src attribute *should* yield an effect #3588
Comments
You can
|
@guest271314 Sorry, I don't understand how your suggestions are related to the problem I described. Could you provide some code examples? Thanks! 🙂 |
The specification section referenced at #3588 (comment) appears to be clear as to dynamically modifying a The use case
can be achieved using various approaches; you can
It should only be necessary to check if the media element can play certain types of media once, before including multiple The media types that are not capable of being played at the media element do not need to be included in HTML at all at |
This makes sense; however it's undesirable. In building a React component I want my
This is a very good point. However, it then doesn't seem like I should be using I understand the capacity to do what I want is there (I already showed a way in my code in the original post). However I'm suggesting that the given |
How did you draw the conclusion that the HTML Have no experience using React. React is not related to HTML Again, there are various approaches which could be used to play media in a specific order using either one or more |
How did you draw the conclusion that the HTML `<source>` element is
intended to be used to cycle through multiple songs?
HTML supports dynamically updating src attributes on single audio elements
to handle multiple songs, and thus a parallel expectation that the same
would hold for source elements is reasonable.
Le ven. 23 mars 2018 14 h 39, guest271314 <notifications@github.com> a
écrit :
… However I'm suggesting that the given <source> children API is not very
useful at all for a context where we want to cycle through multiple songs.
How did you draw the conclusion that the HTML <source> element is
intended to be used to cycle through multiple songs?
Have no experience using React. React is not related to HTML <source>
element, the HTML specification, or the use case of playing multiple songs
in any particular order.
Again, there are various approaches which could be used to play media in a
specific order using either one or more <audio> elements, or Web Audio
API. If the requirement is to use only a single <audio> node, ended event
can still be utilized to render audio in a particular order at that single
element.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3588 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AM7h7dAa_TinXp-xU74coGAc8vz5pIi-ks5thUFOgaJpZM4S4Laa>
.
|
If the requirement is to use multiple
which should "cycle" the playback of the media resource set at
|
|
I'm not sure I follow your 3 steps, much less the code example... Allow me to re-approach my initial query for a moment. I understand the spec is clear about dynamically updating Separately, could any of the browser engine implementers speak to my question about the sharp discrepancy between the spec and MDN on fallback |
The 3 steps explained as an example reflect the requirement of using
Not certain if you are expecting the |
@guest271314 sorry, now I think I understand what you are demonstrating. I was not suggesting I think a list of concurrent source children to a media element should operate as a playlist (this is not how HTMLMediaElement works! 😄 ). I am suggesting I think I should be able to go from: <audio>
<source src="song1.ogg">
<source src="song1.mp3">
</audio> to (by mutating the <audio>
<source src="song2.ogg">
<source src="song3.mp3">
</audio> And the |
That currently does occur. |
This did not appear to be the case based on my own testing, and as I pointed out in my intro post, the spec specifies this will not happen. I'm suggesting that spec should be revisited. |
Have you read the code and checked the |
Please see this code to understand what I mean. https://jsfiddle.net/w0wye78a/ Updates to the |
I tried finding when/where it was decided that changes to I can understand potential motivations for this - the most obvious being the fact changing a bunch of I'd accept this as a reasonable explanation, but at the least, some more specific explanation in the spec could be nice. On the other hand, I'm still eager to know about the reason for the discrepancy on whether failed |
Update - I've determined that specifying Here's a function I'm using for determining the best source to use on subsequent updates: let testAudio;
function getProbableSource(sources) {
testAudio = testAudio || new Audio();
let probableSource;
for (const confidence of ['probably', 'maybe']) {
probableSource = probableSource || sources.find(source => {
return testAudio.canPlayType(source.type) === confidence;
});
}
return probableSource ? probableSource.src : sources[0].src;
} |
Again, the code does not call |
Which should resolve
|
@guest271314 I see! I didn't understand that about your comment earlier (the code example was somewhat dense). It would be useful to include a comment about that in the spec itself under the In my case it's somewhat challenging to implement this well, since ETA: Seems it's sufficient to just check if the |
Closing per the last comment. Let me know if I drew the wrong conclusion. Thanks! |
@annevk I think you're correct, although there were a couple unresolved items:
|
I'd be interested in this too — does anyone have an answer here? I'd be happy to help update the MDN doc if required (or someone else can just edit it if they feel like it) |
tl;dr
Due to confusion about the nature of my request I want to clarify I am not suggesting I should be able to recycle the source list concept in HTML as a sequential playlist. I am merely suggesting I should be able to go from this:
to (by mutating the
src
attributes):And the
currentSrc
should update to use one of the newsrc
attributes on the<source>
children.jsfiddle showing current behavior
original posting
I was reading the
<source>
element spec and came across the following while trying to troubleshoot a bug in my library:Respectfully - I disagree! My component allows a user to specify a sequential playlist of songs to cycle through, and a list of potential sources for each song in the playlist, to be used by the browser as the browser sees fit.
The above quotation implies I am only able to benefit from the browser's automatic source selection for the first song I load. I have to take a totally imperative approach for subsequent tracks, which is a shame in a context like React where I would like to be able to declaratively specify my source list as a function of the currently chosen song index.
What reads simpler to you:
or:
Manually iterating through my source options, checking
canPlayType()
for each, and updating thesrc
attribute seems to me an unnecessarily complicated approach! 😄Sidenote
While reading through both the spec and MDN I came across a notably discrepancy.
Spec
(Emphasis mine)
The quotation refers specifically to images, but I'm assuming it applies to audio and video as well.
MDN
(Emphasis mine again)
Which is it - implementation-wise? If the MDN version turns out to be what's really in the wild, then we're missing a critical feature - automatic mimetype retrieval - when forced to restort to the method of source updating suggested in the spec.
ETA
In my original code example I mapped
this.props.sources
in therender
method - I meant to just mapsources
. This is updated.The text was updated successfully, but these errors were encountered: