Sommerregen / grav-plugin-mediaembed

This plugin embeds several media sites (e.g. YouTube, Vimeo, Soundcloud) by only providing the URL to the medium.
Other
24 stars 8 forks source link

Soundcloud params don't seem to be working #8

Open akoebbe opened 9 years ago

akoebbe commented 9 years ago

I've tried setting the following params settings for Soundcloud, but none of them seem to have any effect...

services:
  SoundCloud:
    enabled: true           # Set to false to disable this service completely
    type: "rich"            # Type of the media service

    example: "https://soundcloud.com/semiseria/verruckert-ausschnitt"

    # URL of media service used for embedding
    url: "w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/{:id}"

    # Canonical URL of media service (used in endpoint calls)
    canonical: "http://soundcloud.com/{:id}"

    # Endpoint to grab media informations
    endpoint: "http://soundcloud.com/oembed?url={:canonical}&format=json"

    # Schemes to grab media id
    schemes:
      - "soundcloud.com/*"
      - "soundcloud.com/*/*"
      - "soundcloud.com/*/sets/*"
      - "soundcloud.com/groups/*"
      - "snd.sc/*"

    params:
      auto_play: true
      buying: true
      download: true
      hide_related: false
      liking: true
      sharing: true
      show_artwork: false
      show_comments: false
      show_playcount: false
      show_user: false
      visual: false

The outputted iframe src is always: https://w.soundcloud.com/player/?visual=true&url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F142154374&show_artwork=true

Sommerregen commented 9 years ago

This is because Rich type Media are currently poorly implemented and doesn't allow setting parameters for the moment (see https://github.com/Sommerregen/grav-plugin-mediaembed/blob/master/classes/OEmbed/OEmbedRich.php#L53). The reason is due to the lack that the specification for rich type media is very unclear (there exists no URL field). Thus I roughly implemented a way to grab at least the correct URL of that media directly from the iframe.

However you are right. Supporting custom param options may be possible be parsing that URL and injecting those params one defines in the mediaembed.yaml.

I will have a look and see whether I can implement such a feature without rewriting too much of the code.