Commit d73f394f authored by Michael Murtaugh's avatar Michael Murtaugh

image sizing, audio glitch

parent 32151305
......@@ -30,9 +30,11 @@
width: 100%;
height: 100%;
}
.holotextbg img {
.holotextbg .image {
width: 100%;
height: 100%;
}
.holotextbg img {}
.holotextbg video {
width: 100%;
}
......@@ -40,6 +42,12 @@
width: 100%;
}
img.center {
display: block;
margin-left: auto !important;
margin-right: auto !important;
}
div.container1 {
position: absolute;
z-index: 1;
......@@ -89,14 +97,39 @@ input.on("command:msg", function (event) {
function do_image (url) {
// this.$image_layer.text("");
if (!hold_image) { image_layer.text(""); }
var img = $("<img />").attr("src", url).appendTo(image_layer);
var img = $("<img />").attr("src", url).addClass("center").appendTo(image_layer);
img.on("load", function () {
// console.log("image loaded", this);
var bg_width = bg.width(),
bg_height = bg.height();
// try using width
// console.log(bg_width, bg_height);
var scale = (bg_width / this.width),
scale_width = bg_width,
scale_height = this.height * scale;
if (scale_height > bg_height) {
// use height
scale_height = bg_height;
scale = bg_height / this.height;
scale_width = this.width * scale;
img.css("height", "100%");
// console.log("use_height", scale_width, scale_height, scale);
} else {
// console.log("use_width", scale_width, scale_height, scale);
// use width
img.css("width", "100%");
}
});
// $("<button>close</button>").click(function () {
// img.remove(); this.remove();
// }).appendTo(bg);
}
function do_audio (url) {
if (!hold_audio) { audio_layer.text(""); }
if (!hold_audio) {
$("audio", bg).each(function () { this.pause(); }).remove();
// audio_layer.text("");
}
var audio= $("<audio autoplay />").attr("src", url).appendTo(audio_layer);
audio.on("ended", function () {
audio.remove();
......@@ -107,7 +140,10 @@ function do_audio (url) {
}
function do_video (url) {
if (!hold_video) { video_layer.text(""); }
if (!hold_video) {
$("video", bg).each(function () { this.pause(); }).remove();
// video_layer.text("");
}
var video = $("<video autoplay />").attr("src", url).appendTo(video_layer);
video.on("ended", function () {
video.remove();
......@@ -131,10 +167,13 @@ function do_message (msg, nick) {
}
} else if (m = msg.match(/^clear (video|audio|image)/i)) {
if (m[1] == "video") {
$("video", bg).remove();
$("video", bg).each(function () { this.pause(); }).remove();
hold_video = false;
} else if (m[1] == "audio") {
$("audio", bg).remove();
$("audio", bg).each(function () {
// console.log("stopping", this);
this.pause();
}).remove();
hold_audio = false;
} else if (m[1] == "image") {
$("img", bg).remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment