Skip to content
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

Add WIP Media Session sample #468

Merged
merged 3 commits into from
Jan 26, 2017

Conversation

beaufortfrancois
Copy link
Member

@beaufortfrancois beaufortfrancois commented Jan 20, 2017

R: @jeffposnick @samdutton

Instead of having to upload one single audio file, I'd like to use some CC audio files from our server. Do you know if we already have some ready?

This sample will be featured in with google/WebFundamentals#4057

FYI: @mounirlamouri @xxyzzzq

Demo: https://beaufortfrancois.github.io/samples/media-session/

let index = 0;

function onPlayButtonClick(event) {
playAudio();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could maybe remove event.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.


/* Seek Backward & Seek Forward */

let skipTime= 10; /* Time to skip in seconds */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: space before =.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing!


function getPlaylist() {
return [{
src: 'jam.ogg',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not crucial, but it would be really nice to have a different audio file for each track :).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samdutton That is my main issue there. Instead of having to upload one single audio file, I'd like to use some CC audio files from our server. Do you know if we already have some?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... I see.

I have one short recording I did of me playing guitar: https://simpl.info/audio/audio/audio.mp3. Of course, you'll still need to add a licence. (I probably should add something to simpl.info, even though it's my recording.) I guess I could do four more if need be (if you can face more of my guitar playing :).

Alternatively, I just found these Sintel recordings (used by Dale Curtis for his MSE gapless playback article: https://developers.google.com/web/updates/2015/06/Media-Source-Extensions-for-Audio):

https://github.com/samdutton/simpl/tree/gh-pages/mse/audio/audio

}];
}

function getArtwork(text) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be inclined just to have these as local images — the getArwork() code adds a bit of complication.

Having said that, it's nice to show that you can get a remote image file.

Hmm...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I know ;)
That's why I've kept it this getArtwork function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


function getArtwork(text) {
return [{
src: 'https://dummyimage.com/96x96?text='+text,
Copy link
Member

@samdutton samdutton Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: spaces around + throughout.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


let skipTime= 10; /* Time to skip in seconds */

navigator.mediaSession.setActionHandler('seekbackward', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I be able to see the seeking controls? I only get previous/next on Android.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should. Which version of Chrome do you have?
image

@beaufortfrancois
Copy link
Member Author

Thanks for your feedback @samdutton!

@beaufortfrancois
Copy link
Member Author

I've decided to use Jan Morgenstern's awesome work. What do you think of it?
Give it a try at https://beaufortfrancois.github.io/samples/media-session/

@samdutton
Copy link
Member

Beautiful! Great choice.

@xxyzzzq
Copy link

xxyzzzq commented Jan 26, 2017

+1 Awesome indeed!

@beaufortfrancois beaufortfrancois merged commit ef369f4 into GoogleChrome:gh-pages Jan 26, 2017
markafoltz pushed a commit that referenced this pull request Oct 14, 2024
* Add WIP Media Session sample

* Address @samdutton feedback

* Use Jan Morgenstern work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants