Add a dynamic label to video selected
-
I have the following to play a video dynamically by specify the media name and its path. There are multiple links on the same page. A user can click on each link to play a video.
I'd also like to add a label somewhere on the screen so the user knows which video he is playing. I tried the following, by calling getTitle with a number to output the title of the video. The problem is it replace the whole screen instead of placing it somewhere on the screen. So how can I achieve what i need? Thanks for your help,
function getTitle(tTitle)
{
myTitle = ""
if (tTitle == 1) {
myTitle = "video 1"
} else if (tTitle == 2) {
myTitle = "video 2"
} else if (tTitle == 3) {
myTitle = "Video 3"
} else if (tTitle == 4) {
myTitle = "Video 4"
}document.write("
");
document.write("Now Playing: " + myTitle);}
-
I have the following to play a video dynamically by specify the media name and its path. There are multiple links on the same page. A user can click on each link to play a video.
I'd also like to add a label somewhere on the screen so the user knows which video he is playing. I tried the following, by calling getTitle with a number to output the title of the video. The problem is it replace the whole screen instead of placing it somewhere on the screen. So how can I achieve what i need? Thanks for your help,
function getTitle(tTitle)
{
myTitle = ""
if (tTitle == 1) {
myTitle = "video 1"
} else if (tTitle == 2) {
myTitle = "video 2"
} else if (tTitle == 3) {
myTitle = "Video 3"
} else if (tTitle == 4) {
myTitle = "Video 4"
}document.write("
");
document.write("Now Playing: " + myTitle);}
I ran your script through a Javascript Lint validator and adjusted it. writeIn will add a linefeed to the end. The value is not an number NAN, and is a string unless your parseInt(tTitle); But I would of just made a span tag with an ID, and wrote the the span tag for the label, and not document write.
function getTitle(tTitle)
{
myTitle = "";
if (tTitle === '1') {
myTitle = "video 1"
} else if (tTitle === '2') {
myTitle = "video 2"
} else if (tTitle === '3') {
myTitle = "Video 3"
} else if (tTitle === '4') {
myTitle = "Video 4"
}document.writeIn('');
document.write('Now Playing: ' + myTitle); -
I ran your script through a Javascript Lint validator and adjusted it. writeIn will add a linefeed to the end. The value is not an number NAN, and is a string unless your parseInt(tTitle); But I would of just made a span tag with an ID, and wrote the the span tag for the label, and not document write.
function getTitle(tTitle)
{
myTitle = "";
if (tTitle === '1') {
myTitle = "video 1"
} else if (tTitle === '2') {
myTitle = "video 2"
} else if (tTitle === '3') {
myTitle = "Video 3"
} else if (tTitle === '4') {
myTitle = "Video 4"
}document.writeIn('');
document.write('Now Playing: ' + myTitle);