Example #1
0
 public function testEmbed()
 {
     $id = static::id();
     $ripple = new Ripple();
     $this->assertSame(self::URL_EMBED . $id, $ripple->embed('SoundCloud', $id));
     $ripple = new Ripple();
     $ripple->setEmbedParams(['SoundCloud' => '?auto_play=true']);
     $this->assertSame(self::URL_EMBED . $id . '?auto_play=true', $ripple->embed('SoundCloud', $id));
 }
Example #2
0
 public function testEmbed()
 {
     $id = static::id();
     $ripple = new Ripple();
     $this->assertSame(self::URL_EMBED . $id, $ripple->embed('Vimeo', $id));
     $ripple = new Ripple();
     $ripple->setEmbedParams(['Vimeo' => '?autoplay=1']);
     $this->assertSame(self::URL_EMBED . $id . '?autoplay=1', $ripple->embed('Vimeo', $id));
 }
Example #3
0
 public function testEmbed()
 {
     $id = static::id();
     $ripple = new Ripple();
     $this->assertSame(self::URL_EMBED . $id . '/', $ripple->embed('Bandcamp', $id));
     $ripple = new Ripple();
     $ripple->setEmbedParams(['Bandcamp' => 'size=large/']);
     $this->assertSame(self::URL_EMBED . $id . '/size=large/', $ripple->embed('Bandcamp', $id));
 }
Example #4
0
 public function testProviders()
 {
     $this->assertSame(['Bandcamp', 'SoundCloud', 'Vimeo', 'YouTube'], Ripple::providers());
 }
Example #5
0
 /**
  * @param string $url
  * @param string $expected
  * @dataProvider validUrlPatternProvider
  */
 public function testValidUrlPattern($url, $expected)
 {
     $ripple = new Ripple($url);
     $this->assertSame($expected, $ripple->isValidUrl());
 }
Example #6
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use jamband\ripple\Ripple;
use Goutte\Client;
// $url = 'https://folkadelphia.bandcamp.com/track/facing-west';
// $url = 'https://soundcloud.com/the-staves/pay-us-no-mind';
// $url = 'https://vimeo.com/67320034';
$url = 'https://www.youtube.com/watch?v=MBlpfXLQLvU';
$ripple = new Ripple($url);
var_dump($ripple->provider());
// YouTube
var_dump($ripple->isValidUrl());
// true
$ripple->request(new Client());
var_dump($ripple->id());
// MBlpfXLQLvU
var_dump($ripple->title());
// The Staves - The Motherlode (Official Video)
var_dump($ripple->image());
// https://i.ytimg.com/vi/MBlpfXLQLvU/hqdefault.jpg
var_dump($ripple->embed());
// https://www.youtube.com/embed/MBlpfXLQLvU
Example #7
0
use jamband\ripple\Ripple;
use Goutte\Client;
// $url = 'https://folkadelphia.bandcamp.com/track/facing-west';
$url = 'https://soundcloud.com/the-staves/pay-us-no-mind';
// $url = 'https://vimeo.com/67320034';
// $url = 'https://www.youtube.com/watch?v=MBlpfXLQLvU';
// simple (set provider name and ID)
$ripple = new Ripple();
var_dump($ripple->embed('YouTube', 'MBlpfXLQLvU'));
// https://www.youtube.com/embed/MBlpfXLQLvU
// append parameter
$ripple->setEmbedParams(['YouTube' => '?autoplay=1']);
var_dump($ripple->embed('YouTube', 'MBlpfXLQLvU'));
// https://www.youtube.com/embed/MBlpfXLQLvU?autoplay=1
// from track url
$ripple = new Ripple($url);
$ripple->request(new Client());
var_dump($ripple->embed());
// https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/42854561
// append parameter
$ripple->setEmbedParams(['YouTube' => '?autoplay=1', 'Vimeo' => '?autoplay=1', 'SoundCloud' => '?auto_play=true&amp;show_comments=false&amp;visual=true', 'Bandcamp' => 'size=large/']);
$embed = $ripple->embed();
var_dump($embed);
// https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/42854561?auto_play=true&amp;show_comments=false&amp;visual=true
?>
<!-- embed HTML -->
<iframe width="300" height="300" src="<?php 
echo $embed;
?>
" frameborder="0" allowfullscreen></iframe>