Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ojii committed Jan 29, 2010
0 parents commit 4d7ed52
Show file tree
Hide file tree
Showing 13 changed files with 806 additions and 0 deletions.
Empty file added jplayer/__init__.py
Empty file.
Binary file added jplayer/__init__.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions jplayer/admin.py
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib.admin.sites import site
from models import JPlayer, Song, Artist, Credits

site.register(JPlayer)
site.register(Song)
site.register(Artist)
site.register(Credits)
Binary file added jplayer/admin.pyc
Binary file not shown.
19 changes: 19 additions & 0 deletions jplayer/cms_plugins.py
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.utils.translation import ugettext_lazy as _

from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase

from jplayer.models import JPlayerIntermediate

class JPlayerPlugin(CMSPluginBase):
model = JPlayerIntermediate
name = _("JPlayer")
render_template = "jplayer/player.html"

def render(self, context, instance, placeholder):
context.update({'player': instance.player})
return context

# include media stuff???

plugin_pool.register_plugin(JPlayerPlugin)
Binary file added jplayer/cms_plugins.pyc
Binary file not shown.
126 changes: 126 additions & 0 deletions jplayer/media/js/cmsplayer.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,126 @@
function cmsplayer_ready (element, playlist, autoplay, playerid)
{
var playItem = 0;

element.jPlayerId("play", "player_play_"+playerid)
.jPlayerId("pause", "player_pause_"+playerid)
.jPlayerId("stop", "player_stop_"+playerid)
.jPlayerId("loadBar", "player_progress_load_bar_"+playerid)
.jPlayerId("playBar", "player_progress_play_bar_"+playerid)
.jPlayerId("volumeMin", "player_volume_min_"+playerid)
.jPlayerId("volumeMax", "player_volume_max_"+playerid)
.jPlayerId("volumeBar", "player_volume_bar_"+playerid)
.jPlayerId("volumeBarValue", "player_volume_bar_value_"+playerid)
.onProgressChange( function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
var myPlayedTime = new Date(playedTime);
var ptMin = (myPlayedTime.getUTCMinutes() < 10) ? "0" + myPlayedTime.getUTCMinutes() : myPlayedTime.getUTCMinutes();
var ptSec = (myPlayedTime.getUTCSeconds() < 10) ? "0" + myPlayedTime.getUTCSeconds() : myPlayedTime.getUTCSeconds();
$("#play_time_"+playerid).text(ptMin+":"+ptSec);

var myTotalTime = new Date(totalTime);
var ttMin = (myTotalTime.getUTCMinutes() < 10) ? "0" + myTotalTime.getUTCMinutes() : myTotalTime.getUTCMinutes();
var ttSec = (myTotalTime.getUTCSeconds() < 10) ? "0" + myTotalTime.getUTCSeconds() : myTotalTime.getUTCSeconds();
$("#total_time_"+playerid).text(ttMin+":"+ttSec);
});

element.onSoundComplete( function() {
playListNext();
});

$("#ctrl_prev_"+playerid).click( function() {
playListPrev();
return false;
});

$("#ctrl_next_"+playerid).click( function() {
playListNext();
return false;
});

function displayPlayList() {
for (i=0; i < playlist.length; i++) {
song = playlist[i];
display = "<li class='song' id='playlist_item_"+playerid+"_'"+i+"'><span class='songname' id='cmsplay_song_'"+i+"'>"+song.name + '</span> - ';
if (song.artist_url)
{
display+=" <a class='artist' href='"+song.artist_url+"'>"+song.artist_name+"</a>";
}
else
{
display+=" <span class='artist'>"+song.artist_name+"</span>";
}
if (song.credits_name)
{
if (song.credits_url)
{
display+=" - <a class='credits' href='"+song.credits_url+"'>"+song.credits_name+"</a>";
}
else
{
display+=" - <span class='credits'>"+song.credits_name+"</span>";
}
}
$("#playlist_list_"+playerid +" ul").append(display);
$("#playlist_item_"+playerid+"_"+i).data( "index", i ).hover(
function() {
if (playItem != $(this).data("index")) {
$(this).addClass("playlist_hover");
}
},
function() {
$(this).removeClass("playlist_hover");
}
)
$('#cmsplay_song_'+playerid+'_'+i).click( function() {
var index = $(this).data("index");
if (playItem != index) {
playListChange( index );
} else {
$("#jquery_jplayer_"+playerid).play();
}
});
}
}

function playListInit(autoplay) {
if(autoplay) {
playListChange( playItem );
} else {
playListConfig( playItem );
}
}

function playListConfig( index ) {
$("#playlist_item_"+playerid+"_"+playItem).removeClass("playlist_current");
$("#playlist_item_"+playerid+"_"+index).addClass("playlist_current");
playItem = index;
if (playlist[playItem].ogg)
{
$("#jquery_jplayer_"+playerid).setFile(playlist[playItem].mp3, myPlayList[playItem].ogg);
}
else
{
$("#jquery_jplayer_"+playerid).setFile(playlist[playItem].mp3);
}
}

function playListChange( index ) {
playListConfig( index );
$("#jquery_jplayer_"+playerid).play();
}

function playListNext() {
var index = (playItem+1 < playlist.length) ? playItem+1 : 0;
playListChange( index );
}

function playListPrev() {
var index = (playItem-1 >= 0) ? playItem-1 : playlist.length-1;
playListChange( index );
}

displayPlayList();
playListInit(autoplay);
}

jQuery.cmsplayer_ready = cmsplayer_ready;
Loading

0 comments on commit 4d7ed52

Please sign in to comment.