mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-26 06:57:58 +01:00
finished embed code
This commit is contained in:
parent
f9be5c4728
commit
2d43bf64af
9 changed files with 511 additions and 35 deletions
|
@ -10,11 +10,41 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmbed($id) {
|
public function getEmbed($id) {
|
||||||
$track = Track::find($id);
|
$track = Track
|
||||||
|
::whereId($id)
|
||||||
|
->published()
|
||||||
|
->userDetails()
|
||||||
|
->with(
|
||||||
|
'user',
|
||||||
|
'user.avatar',
|
||||||
|
'genre'
|
||||||
|
)->first();
|
||||||
|
|
||||||
if (!$track || !$track->canView(Auth::user()))
|
if (!$track || !$track->canView(Auth::user()))
|
||||||
App::abort(404);
|
App::abort(404);
|
||||||
|
|
||||||
return View::make('tracks.embed', ['track' => $track]);
|
$userData = [
|
||||||
|
'stats' => [
|
||||||
|
'views' => 0,
|
||||||
|
'plays' => 0,
|
||||||
|
'downloads' => 0
|
||||||
|
],
|
||||||
|
'is_favourited' => false
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($track->users->count()) {
|
||||||
|
$userRow = $track->users[0];
|
||||||
|
$userData = [
|
||||||
|
'stats' => [
|
||||||
|
'views' => $userRow->view_count,
|
||||||
|
'plays' => $userRow->play_count,
|
||||||
|
'downloads' => $userRow->download_count,
|
||||||
|
],
|
||||||
|
'is_favourited' => $userRow->is_favourited
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return View::make('tracks.embed', ['track' => $track, 'user' => $userData]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrack($id, $slug) {
|
public function getTrack($id, $slug) {
|
||||||
|
|
|
@ -82,6 +82,22 @@
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
} else if ($area == 'embed') {
|
||||||
|
$collection = new AssetCollection([
|
||||||
|
new FileAsset('scripts/base/jquery-2.0.2.js'),
|
||||||
|
new FileAsset('scripts/base/jquery.viewport.js'),
|
||||||
|
new FileAsset('scripts/base/underscore.js'),
|
||||||
|
new FileAsset('scripts/base/moment.js'),
|
||||||
|
new FileAsset('scripts/base/jquery.timeago.js'),
|
||||||
|
new FileAsset('scripts/base/soundmanager2-nodebug.js'),
|
||||||
|
new AssetCollection([
|
||||||
|
new GlobAsset('scripts/embed/*.coffee'),
|
||||||
|
], [
|
||||||
|
new CoffeeScriptFilter(Config::get('app.coffee'))
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +120,12 @@
|
||||||
$css->add(new FileAsset('styles/prettify.css'));
|
$css->add(new FileAsset('styles/prettify.css'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $css;
|
||||||
|
} else if ($area == 'embed') {
|
||||||
|
$css = new AssetCollection([
|
||||||
|
new FileAsset('styles/embed.less'),
|
||||||
|
], [new \Assetic\Filter\LessFilter('node')]);
|
||||||
|
|
||||||
return $css;
|
return $css;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,20 @@
|
||||||
|
|
||||||
return round($bytes, $precision) . ' ' . $units[$pow];
|
return round($bytes, $precision) . ' ' . $units[$pow];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* timeago-style timestamp generator macro.
|
||||||
|
*
|
||||||
|
* @param string $timestamp A timestamp in SQL DATETIME syntax
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function timestamp( $timestamp ) {
|
||||||
|
if(gettype($timestamp) !== 'string' && get_class($timestamp) === 'DateTime'){
|
||||||
|
$timestamp = $timestamp->format('c');
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = date('c', strtotime($timestamp));
|
||||||
|
$content = date('F d, o \@ g:i:s a', strtotime($timestamp));
|
||||||
|
return '<abbr class="timeago" title="'.$title.'">'.$content.'</abbr>';
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,10 +2,8 @@
|
||||||
<html lang="en-CA">
|
<html lang="en-CA">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>@section('title')Pony.fm
|
<title>{{$track->title}} by {{$track->user->display_name}} on Pony.fm</title>
|
||||||
@yield_section</title>
|
|
||||||
<meta itemprop="name" content="Pony.fm">
|
<meta itemprop="name" content="Pony.fm">
|
||||||
{{-- <meta itemprop="image" content="https://pony.fm/favicon.ico"> --}}
|
|
||||||
<meta property="og:title" content="Pony.fm - The Pony Music Hosting Site" />
|
<meta property="og:title" content="Pony.fm - The Pony Music Hosting Site" />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:url" content="https://pony.fm/" />
|
<meta property="og:url" content="https://pony.fm/" />
|
||||||
|
@ -13,55 +11,46 @@
|
||||||
<meta property="og:site_name" content="Pony.fm" />
|
<meta property="og:site_name" content="Pony.fm" />
|
||||||
<meta property="fb:admins" content="1165335382" />
|
<meta property="fb:admins" content="1165335382" />
|
||||||
|
|
||||||
{{ HTML::style( 'css/app-embed.css?' . filemtime(path('public').'/css/app.css') ) }}
|
{{ Assets::styleIncludes('embed') }}
|
||||||
{{ Asset::styles() }}
|
|
||||||
|
|
||||||
<?php Asset::add('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'); ?>
|
|
||||||
<?php Asset::add('jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js', 'jquery'); ?>
|
|
||||||
<?php Asset::add('scripts', 'js/app.js?' . filemtime(path('public').'/js/app.js'), 'jquery'); ?>
|
|
||||||
</head>
|
</head>
|
||||||
<body class="embed">
|
<body>
|
||||||
<div class="fixed-image-width">
|
@if($track->explicit && !(Auth::check() && Auth::user()->can_see_explicit_content))
|
||||||
@if($track->explicit && !(Auth::check() && Auth::user()->can_see_explicit_content))
|
<div class="explicit alert alert-danger">
|
||||||
<div class="explicit alert-box alert">
|
<em>Enable explicit content in {{ HTML::link(URL::to('/account/settings'), 'your account', ['target' => '_blank']) }} to play this track.</em>
|
||||||
<em>Enable explicit content in {{ HTML::link(URL::to_action('account@edit'), 'your account', ['target' => '_blank']) }} to play this track.</em>
|
|
||||||
|
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
<span>Hosted by <a href="{{URL::to('/')}}" target="_blank">Pony.fm</a></span>
|
<span>Hosted by <a href="{{URL::to('/')}}" target="_blank">Pony.fm</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="player-small {{Auth::check() ? 'can-favourite' : ''}} {{Track_Plays::hasPlayed($track->id) ? 'played' : 'unplayed'}} {{Track_Plays::hasFavourited($track->id) ? 'favourited' : ''}}" data-track-id="{{ $track->id }}" data-duration="{{ $track->duration * 1000 }}">
|
<div class="player loading {{Auth::check() ? 'can-favourite' : ''}} {{$user['is_favourited'] ? 'favourited' : ''}}" data-track-id="{{ $track->id }}" data-duration="{{ $track->duration * 1000 }}">
|
||||||
<div class="play" disabled="disabled">
|
<div class="play" disabled="disabled">
|
||||||
<div><i class="icon-play icon-1x"></i></div>
|
<div class="button"><i class="icon-play"></i></div>
|
||||||
{{ HTML::image($track->get_cover_url('normal')) }}
|
{{ HTML::image($track->getCoverUrl(\Entities\Image::SMALL)) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
@if (Auth::check())
|
@if (Auth::check())
|
||||||
<a href="#" class="favourite"><i title="Favourite this track!" class="favourite-icon icon-star-empty"></i></a>
|
<a href="#" class="favourite"><i title="Favourite this track!" class="favourite-icon icon-star-empty"></i></a>
|
||||||
@endif
|
@endif
|
||||||
<div class="progressbar">
|
<div class="progressbar">
|
||||||
<div class="progress-container">
|
<div class="loader"></div>
|
||||||
<div class="loader"></div>
|
<div class="seeker"></div>
|
||||||
<div class="seeker"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<span class="title">{{ HTML::link( $track->url, $track->title, ['target' => '_blank'] ) }}</span>
|
<span class="title">{{ HTML::link( $track->url, $track->title, ['target' => '_blank'] ) }}</span>
|
||||||
<span>by: <strong>{{ HTML::link($track->user->url, $track->artist, ['target' => '_blank']) }}</strong> / {{ HTML::link($track->genre->url, $track->genre->title, ['target' => '_blank']) }} / {{ HTML::timestamp($track->published_at) }}</span>
|
<span>by: <strong>{{ HTML::link($track->user->url, $track->user->display_name, ['target' => '_blank']) }}</strong> / {{$track->genre->name}} / {{Helpers::timestamp($track->published_at)}}</span>
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
Views: <strong>{{ $track->views }}</strong> / Plays: <strong>{{ $track->plays }}</strong> / Downloads: <strong>{{ $track->downloads }}</strong> /
|
Views: <strong>{{ $track->view_count }}</strong> / Plays: <strong>{{ $track->play_count }}</strong> / Downloads: <strong>{{ $track->download_count }}</strong> /
|
||||||
<span>Hosted by <a href="{{URL::to('/')}}" target="_blank">Pony.fm</a></span>
|
<span>Hosted by <a href="{{URL::to('/')}}" target="_blank">Pony.fm</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var pfm = {token: '{{ Session::token() }}'}
|
var pfm = {token: '{{ Session::token() }}'}
|
||||||
</script>
|
</script>
|
||||||
{{ Asset::scripts() }}
|
|
||||||
|
{{ Assets::scriptIncludes('embed') }}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
_gaq.push(['_setAccount', 'UA-29463256-1']);
|
_gaq.push(['_setAccount', 'UA-29463256-1']);
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
angular.module('ponyfm').controller "uploader", [
|
angular.module('ponyfm').controller "uploader", [
|
||||||
'$scope', 'auth', 'upload', '$state'
|
'$scope', 'auth', 'upload', '$state'
|
||||||
($scope, auth, upload, $state) ->
|
($scope, auth, upload, $state) ->
|
||||||
|
|
||||||
$scope.data = upload
|
$scope.data = upload
|
||||||
|
|
||||||
$scope.$on 'upload-finished', (e, upload) ->
|
|
||||||
]
|
]
|
193
public/scripts/base/jquery.timeago.js
Normal file
193
public/scripts/base/jquery.timeago.js
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
/**
|
||||||
|
* Timeago is a jQuery plugin that makes it easy to support automatically
|
||||||
|
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
|
||||||
|
*
|
||||||
|
* @name timeago
|
||||||
|
* @version 1.3.0
|
||||||
|
* @requires jQuery v1.2.3+
|
||||||
|
* @author Ryan McGeary
|
||||||
|
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
|
||||||
|
*
|
||||||
|
* For usage and examples, visit:
|
||||||
|
* http://timeago.yarp.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function (factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define(['jquery'], factory);
|
||||||
|
} else {
|
||||||
|
// Browser globals
|
||||||
|
factory(jQuery);
|
||||||
|
}
|
||||||
|
}(function ($) {
|
||||||
|
$.timeago = function(timestamp) {
|
||||||
|
if (timestamp instanceof Date) {
|
||||||
|
return inWords(timestamp);
|
||||||
|
} else if (typeof timestamp === "string") {
|
||||||
|
return inWords($.timeago.parse(timestamp));
|
||||||
|
} else if (typeof timestamp === "number") {
|
||||||
|
return inWords(new Date(timestamp));
|
||||||
|
} else {
|
||||||
|
return inWords($.timeago.datetime(timestamp));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var $t = $.timeago;
|
||||||
|
|
||||||
|
$.extend($.timeago, {
|
||||||
|
settings: {
|
||||||
|
refreshMillis: 60000,
|
||||||
|
allowFuture: false,
|
||||||
|
localeTitle: false,
|
||||||
|
cutoff: 0,
|
||||||
|
strings: {
|
||||||
|
prefixAgo: null,
|
||||||
|
prefixFromNow: null,
|
||||||
|
suffixAgo: "ago",
|
||||||
|
suffixFromNow: "from now",
|
||||||
|
seconds: "less than a minute",
|
||||||
|
minute: "about a minute",
|
||||||
|
minutes: "%d minutes",
|
||||||
|
hour: "about an hour",
|
||||||
|
hours: "about %d hours",
|
||||||
|
day: "a day",
|
||||||
|
days: "%d days",
|
||||||
|
month: "about a month",
|
||||||
|
months: "%d months",
|
||||||
|
year: "about a year",
|
||||||
|
years: "%d years",
|
||||||
|
wordSeparator: " ",
|
||||||
|
numbers: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inWords: function(distanceMillis) {
|
||||||
|
var $l = this.settings.strings;
|
||||||
|
var prefix = $l.prefixAgo;
|
||||||
|
var suffix = $l.suffixAgo;
|
||||||
|
if (this.settings.allowFuture) {
|
||||||
|
if (distanceMillis < 0) {
|
||||||
|
prefix = $l.prefixFromNow;
|
||||||
|
suffix = $l.suffixFromNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var seconds = Math.abs(distanceMillis) / 1000;
|
||||||
|
var minutes = seconds / 60;
|
||||||
|
var hours = minutes / 60;
|
||||||
|
var days = hours / 24;
|
||||||
|
var years = days / 365;
|
||||||
|
|
||||||
|
function substitute(stringOrFunction, number) {
|
||||||
|
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
|
||||||
|
var value = ($l.numbers && $l.numbers[number]) || number;
|
||||||
|
return string.replace(/%d/i, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
|
||||||
|
seconds < 90 && substitute($l.minute, 1) ||
|
||||||
|
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
|
||||||
|
minutes < 90 && substitute($l.hour, 1) ||
|
||||||
|
hours < 24 && substitute($l.hours, Math.round(hours)) ||
|
||||||
|
hours < 42 && substitute($l.day, 1) ||
|
||||||
|
days < 30 && substitute($l.days, Math.round(days)) ||
|
||||||
|
days < 45 && substitute($l.month, 1) ||
|
||||||
|
days < 365 && substitute($l.months, Math.round(days / 30)) ||
|
||||||
|
years < 1.5 && substitute($l.year, 1) ||
|
||||||
|
substitute($l.years, Math.round(years));
|
||||||
|
|
||||||
|
var separator = $l.wordSeparator || "";
|
||||||
|
if ($l.wordSeparator === undefined) { separator = " "; }
|
||||||
|
return $.trim([prefix, words, suffix].join(separator));
|
||||||
|
},
|
||||||
|
parse: function(iso8601) {
|
||||||
|
var s = $.trim(iso8601);
|
||||||
|
s = s.replace(/\.\d+/,""); // remove milliseconds
|
||||||
|
s = s.replace(/-/,"/").replace(/-/,"/");
|
||||||
|
s = s.replace(/T/," ").replace(/Z/," UTC");
|
||||||
|
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
|
||||||
|
return new Date(s);
|
||||||
|
},
|
||||||
|
datetime: function(elem) {
|
||||||
|
var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
|
||||||
|
return $t.parse(iso8601);
|
||||||
|
},
|
||||||
|
isTime: function(elem) {
|
||||||
|
// jQuery's `is()` doesn't play well with HTML5 in IE
|
||||||
|
return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions that can be called via $(el).timeago('action')
|
||||||
|
// init is default when no action is given
|
||||||
|
// functions are called with context of a single element
|
||||||
|
var functions = {
|
||||||
|
init: function(){
|
||||||
|
var refresh_el = $.proxy(refresh, this);
|
||||||
|
refresh_el();
|
||||||
|
var $s = $t.settings;
|
||||||
|
if ($s.refreshMillis > 0) {
|
||||||
|
setInterval(refresh_el, $s.refreshMillis);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update: function(time){
|
||||||
|
$(this).data('timeago', { datetime: $t.parse(time) });
|
||||||
|
refresh.apply(this);
|
||||||
|
},
|
||||||
|
updateFromDOM: function(){
|
||||||
|
$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
|
||||||
|
refresh.apply(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.timeago = function(action, options) {
|
||||||
|
var fn = action ? functions[action] : functions.init;
|
||||||
|
if(!fn){
|
||||||
|
throw new Error("Unknown function name '"+ action +"' for timeago");
|
||||||
|
}
|
||||||
|
// each over objects here and call the requested function
|
||||||
|
this.each(function(){
|
||||||
|
fn.call(this, options);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
var data = prepareData(this);
|
||||||
|
var $s = $t.settings;
|
||||||
|
|
||||||
|
if (!isNaN(data.datetime)) {
|
||||||
|
if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) {
|
||||||
|
$(this).text(inWords(data.datetime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareData(element) {
|
||||||
|
element = $(element);
|
||||||
|
if (!element.data("timeago")) {
|
||||||
|
element.data("timeago", { datetime: $t.datetime(element) });
|
||||||
|
var text = $.trim(element.text());
|
||||||
|
if ($t.settings.localeTitle) {
|
||||||
|
element.attr("title", element.data('timeago').datetime.toLocaleString());
|
||||||
|
} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
|
||||||
|
element.attr("title", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return element.data("timeago");
|
||||||
|
}
|
||||||
|
|
||||||
|
function inWords(date) {
|
||||||
|
return $t.inWords(distance(date));
|
||||||
|
}
|
||||||
|
|
||||||
|
function distance(date) {
|
||||||
|
return (new Date().getTime() - date.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix for IE6 suckage
|
||||||
|
document.createElement("abbr");
|
||||||
|
document.createElement("time");
|
||||||
|
}));
|
12
public/scripts/embed/favourite.coffee
Normal file
12
public/scripts/embed/favourite.coffee
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
$player = $ '.player'
|
||||||
|
$favourite = $player.find '.favourite'
|
||||||
|
trackId = $player.data 'track-id'
|
||||||
|
|
||||||
|
$favourite.click (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
$.post('/api/web/favourites/toggle', {type: 'track', id: trackId, _token: pfm.token}).done (res) ->
|
||||||
|
if res.is_favourited
|
||||||
|
$player.addClass 'favourited'
|
||||||
|
else
|
||||||
|
$player.removeClass 'favourited'
|
81
public/scripts/embed/player.coffee
Normal file
81
public/scripts/embed/player.coffee
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
$('.timeago').timeago()
|
||||||
|
|
||||||
|
loaderDef = new $.Deferred()
|
||||||
|
|
||||||
|
soundManager.setup
|
||||||
|
url: '/flash/soundmanager/'
|
||||||
|
flashVersion: 9
|
||||||
|
onready: () ->
|
||||||
|
loaderDef.resolve()
|
||||||
|
|
||||||
|
loaderDef.done ->
|
||||||
|
$player = $('.player')
|
||||||
|
$play = $('.player .play')
|
||||||
|
$progressBar = $player.find '.progressbar'
|
||||||
|
$loadingBar = $progressBar.find '.loader'
|
||||||
|
$seekBar = $progressBar.find '.seeker'
|
||||||
|
currentSound = null
|
||||||
|
isPlaying = false
|
||||||
|
trackId = $player.data('track-id')
|
||||||
|
duration = $player.data('duration')
|
||||||
|
|
||||||
|
$player.removeClass 'loading'
|
||||||
|
|
||||||
|
setPlaying = (playing) ->
|
||||||
|
isPlaying = playing
|
||||||
|
if playing
|
||||||
|
$player.addClass 'playing'
|
||||||
|
$player.removeClass 'paused'
|
||||||
|
else
|
||||||
|
$player.addClass 'paused'
|
||||||
|
$player.removeClass 'playing'
|
||||||
|
|
||||||
|
$progressBar.click (e) ->
|
||||||
|
return if !currentSound
|
||||||
|
percent = ((e.pageX - $progressBar.offset().left) / $progressBar.width())
|
||||||
|
duration = parseFloat(duration)
|
||||||
|
progress = percent * duration
|
||||||
|
currentSound.setPosition(progress)
|
||||||
|
|
||||||
|
$play.click ->
|
||||||
|
if currentSound
|
||||||
|
if isPlaying
|
||||||
|
currentSound.pause()
|
||||||
|
else
|
||||||
|
currentSound.play()
|
||||||
|
else
|
||||||
|
currentSound = soundManager.createSound
|
||||||
|
url: '/t' + trackId + '/stream',
|
||||||
|
volume: 50
|
||||||
|
|
||||||
|
whileloading: ->
|
||||||
|
loadingProgress = (currentSound.bytesLoaded / currentSound.bytesTotal) * 100
|
||||||
|
$loadingBar.css
|
||||||
|
width: loadingProgress + '%'
|
||||||
|
|
||||||
|
whileplaying: ->
|
||||||
|
progress = (currentSound.position / (duration)) * 100
|
||||||
|
$seekBar.css
|
||||||
|
width: progress + '%'
|
||||||
|
|
||||||
|
onfinish: ->
|
||||||
|
setPlaying false
|
||||||
|
currentSound = null
|
||||||
|
$loadingBar.css {width: '0'}
|
||||||
|
$seekBar.css {width: '0'}
|
||||||
|
$player.removeClass 'playing'
|
||||||
|
$player.removeClass 'paused'
|
||||||
|
|
||||||
|
onstop: ->
|
||||||
|
setPlaying false
|
||||||
|
|
||||||
|
onplay: ->
|
||||||
|
|
||||||
|
onresume: ->
|
||||||
|
setPlaying true
|
||||||
|
|
||||||
|
onpause: ->
|
||||||
|
setPlaying false
|
||||||
|
|
||||||
|
setPlaying true
|
||||||
|
currentSound.play()
|
136
public/styles/embed.less
Normal file
136
public/styles/embed.less
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
@import 'base/bootstrap/bootstrap';
|
||||||
|
@import 'base/bootstrap/responsive';
|
||||||
|
@import 'base/font-awesome/font-awesome';
|
||||||
|
@import 'variables';
|
||||||
|
@import 'mixins';
|
||||||
|
|
||||||
|
body {
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #C2889C;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.player {
|
||||||
|
|
||||||
|
&.playing .play .button i:before {
|
||||||
|
content: "\f04c";
|
||||||
|
}
|
||||||
|
|
||||||
|
&.favourited .meta .favourite {
|
||||||
|
color: @orange;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: #FFD76E;
|
||||||
|
text-shadow: 0px 0px 2px rgba(0,0,0,0.8);
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: "\f005"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.play {
|
||||||
|
.img-polaroid();
|
||||||
|
|
||||||
|
float: left;
|
||||||
|
width: 100px;
|
||||||
|
padding: 3px;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.button {
|
||||||
|
background: rgba(0, 0, 0, 1);
|
||||||
|
border: 3px solid rgba(255, 255, 255, .9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
.border-radius(60px);
|
||||||
|
.transition(all 250ms ease-out);
|
||||||
|
|
||||||
|
border: 3px solid rgba(255, 255, 255, .6);
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
position: absolute;
|
||||||
|
top: 35px;
|
||||||
|
left: 35px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 32px;
|
||||||
|
color: #fff;
|
||||||
|
background: rgba(0, 0, 0, .4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta {
|
||||||
|
margin-left: 115px;
|
||||||
|
font-size: 11px;
|
||||||
|
|
||||||
|
.favourite {
|
||||||
|
display: block;
|
||||||
|
float: right;
|
||||||
|
font-size: 18px;
|
||||||
|
margin-top: -3px;
|
||||||
|
color: #2795b6;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
.ellipsis();
|
||||||
|
margin-top: 5px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressbar {
|
||||||
|
cursor: pointer;
|
||||||
|
height: 11px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #888;
|
||||||
|
margin-right: 27px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.loader, .seeker {
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.seeker {
|
||||||
|
background: @pfm-purple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 5px;
|
||||||
|
right: 5px;
|
||||||
|
font-size: 8pt;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue