mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
Oembed stuffs
This commit is contained in:
parent
78501007ce
commit
2dd6c663ff
3 changed files with 39 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace Poniverse\Ponyfm\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Poniverse\Ponyfm\Models\ResourceLogItem;
|
||||
use Poniverse\Ponyfm\Models\Track;
|
||||
use Poniverse\Ponyfm\Models\TrackFile;
|
||||
|
@ -77,6 +78,41 @@ class TracksController extends Controller
|
|||
return View::make('tracks.embed', ['track' => $track, 'user' => $userData]);
|
||||
}
|
||||
|
||||
public function getOembed(Request $request)
|
||||
{
|
||||
if (!$request->has('url')) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
$parsedUrl = parse_url($request->input('url'));
|
||||
$id = preg_match('(\d+)', $parsedUrl['path']);
|
||||
|
||||
$track = Track
|
||||
::whereId($id)
|
||||
->published()
|
||||
->userDetails()
|
||||
->first();
|
||||
|
||||
if (!$track || !$track->canView(Auth::user())) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
$output = [
|
||||
'version' => '1.0',
|
||||
'type' => 'rich',
|
||||
'provider_name' => 'Pony.fm',
|
||||
'provider_url' => 'https://pony.fm',
|
||||
'width' => 480,
|
||||
'height' => 130,
|
||||
'title' => $track->title,
|
||||
'author_name' => $track->user->display_name,
|
||||
'author_url' => $track->user->url,
|
||||
'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>'
|
||||
];
|
||||
|
||||
return Response::json($output);
|
||||
}
|
||||
|
||||
public function getTrack($id, $slug)
|
||||
{
|
||||
$track = Track::find($id);
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
<meta name="twitter:player:height" content="130" />
|
||||
<meta name="twitter:player:stream" content="{{ $track->getStreamUrl('MP3') }}" />
|
||||
<meta name="twitter:player:stream:content_type" content="audio/mpeg" />
|
||||
|
||||
<link rel="alternate" type="application/json+oembed" href="{{ url('/oembed?url=') . url('tracks/' . $track->id . '-' . $track->slug) }}" title="{{ $track->title }}" />
|
||||
@endsection
|
||||
|
||||
@section('app_content')
|
||||
|
|
|
@ -77,7 +77,7 @@ Route::get('p{id}/dl.{extension}', 'PlaylistsController@getDownload');
|
|||
|
||||
Route::get('notifications', 'AccountController@getNotifications');
|
||||
|
||||
|
||||
Route::get('oembed', 'TracksController@getOembed');
|
||||
|
||||
Route::group(['prefix' => 'api/v1', 'middleware' => 'json-exceptions'], function () {
|
||||
Route::get('/tracks/radio-details/{hash}', 'Api\V1\TracksController@getTrackRadioDetails');
|
||||
|
|
Loading…
Reference in a new issue