我需要将此 Id 放入单个video
输入标签中。我需要将player
及其行ID放在php
中,我已经这样做了
虽然没有用,但是我缺少什么还是什么?谢谢,这是我的代码
<video preload controls playsinline id="player[<?php echo ''.$row5['id'].'';?>]" width="100%"></video>
<?php echo ''.$row5['id'].'';?>
来自此代码data-id
属性
代码
<div data-id="<?php echo ''.$row5['id'].'';?>"><img src="images/gems.png" width="33px"></div>
这就是它的工作原理,当单击图像时,视频应根据图像的ID播放其ID。
我只需要将其与player
id一起使用,因为没有它,视频将无法播放。
JavaScript代码
var episodeid = $(this).data('id');
var pelement = document.getElementById(episodeid);
$.ajax({
type: "POST",
url: "check-series.php",
data: {episodeid:episodeid},
dataType: "text",
async: false,
success: function(data) {
if(data == '1'){
if (pelement.mozRequestFullScreen) {
$("#myModal2").show();
}
else if (pelement.webkitRequestFullScreen) {
$("#myModal2").show();
}
document.getElementById(episodeid).play();
}
else {
$.confirm({
title: 'Purchase episode?',
content: 'You are about to buy ' + episodetitle + '.' ,
theme: 'supervan',
buttons: {
confirm: function () {
$.alert('Proceeding to payments page..');
window.location.href = "paymentmethod.php?id=" + episodeid;
},
cancel: function () {
$.alert('You have cancelled your purchase!');
}
}
});
}
},
error: function(err) {
console.log(err);
}
});
});
答案 0 :(得分:1)
我进行了快速测试,您的代码有效。
<?php $row5['id'] = 123; ?>
<video preload controls playsinline id="player[<?php echo ''.$row5['id'].'';?>]" width="100%"></video>
输出:
<video preload controls playsinline id="player[123]" width="100%"></video>
即使删除多余的''引号,将值设置为null仍然有效。您不需要它们。
<?php $row5['id'] = null; ?>
<video preload controls playsinline id="player[<?php echo ''.$row5['id'].'';?>]" width="100%"></video>
<video preload controls playsinline id="player[<?php echo $row5['id'];?>]" width="100%"></video>
输出:
<video preload controls playsinline id="player[]" width="100%"></video>
<video preload controls playsinline id="player[]" width="100%"></video>
答案 1 :(得分:0)
您的视频的ID如try {
JSONObject match = new JSONObject(response);
if (match.has("group")) {
JSONObject group = match.getJSONObject("group");
if (group.has("Teams")) {
JSONArray teams = group.getJSONArray("Teams");
if (teams.length() > 0) {
JSONObject teams_object =(JSONObject) teams.get(0);
String team_name = teams_object.getString("name");
String matches_played = teams_object.getString("p");
String matches_won = teams_object.getString("w");
String matches_lost = teams_object.getString("l");
String points = teams_object.getString("points");
Log.v(TAG, team_name);
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
。但是在DIV中,您有id="player[123]"
。您没有在data-id="123"
属性的ID号周围加上player[]
。将DIV更改为:
data-id
因此<div data-id="player[<?php echo $row5['id'];?>]"><img src="images/gems.png" width="33px"></div>
的值与视频的完整ID匹配。