Skip to content

Commit

Permalink
fix play stream
Browse files Browse the repository at this point in the history
  • Loading branch information
nambuplace committed Jul 25, 2019
1 parent 2096635 commit c6db621
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 16 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ TVRemotePlus は、PWA に対応しています。
- 同梱している動作に必要なソフトウェア(後述)は全て TVRemotePlus 向けに設定やフォルダ構成等を最適化してあります。

## 既知の問題
- ライブ再生がなかなか始まらない → 将来的に修正予定ですが、今は何度かリロードしてください(大体直ります)
- ファイル再生が不安定 → 将来的に修正予定ですが、今は何度かリロードしてください(これも大体直ります)
- ストリームが起動しているかどうかを監視する機能を実装出来ていないため、ストリーム起動に失敗したかは PC のエンコーダーのログを見ない限り分からない
- 何度リロードしても「配信準備中…」の動画が流れる場合、ストリーム起動に失敗している可能性が高いです
- ストリームを終了させる際、ffmpeg・QSVEnc・TSTask 等を taskkill で強制終了させる雑な仕様なため、ストリーム起動時にffmpegなど別のソフトを利用している場合に突然ブッチされる
Expand Down
5 changes: 5 additions & 0 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<link rel="stylesheet" type="text/css" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" type="text/css" href="files/DPlayer.min.css">
<link rel="stylesheet" type="text/css" href="files/toastr.min.css">
<link rel="stylesheet" type="text/css" href="files/style.css">
<?php
if (strpos($backtrace[0]["file"], 'watch.php') !== false){ // watch.phpのみ
Expand All @@ -41,10 +42,14 @@
<script type="text/javascript" src="files/jquery.min.js"></script>
<script type="text/javascript" src="files/DPlayer.min.js"></script>
<script type="text/javascript" src="files/hls.min.js"></script>
<script type="text/javascript" src="files/toastr.min.js"></script>
<?php
if (strpos($backtrace[0]["file"], 'index.php') !== false){ // index.phpのみ
echo '<script type="text/javascript" src="files/resize.js"></script>';
}
if (strpos($backtrace[0]["file"], 'setting.php') !== false){ // setting.phpのみ
echo '<script type="text/javascript" src="files/resize.js"></script>';
}
if (strpos($backtrace[0]["file"], 'watch.php') !== false){ // watch.phpのみ
echo '<script type="text/javascript" src="files/watch.js"></script>';
} else if ($ini['state'] == 'ONAir'){
Expand Down
4 changes: 2 additions & 2 deletions htdocs/files/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// 何故か上手くいかないので6回繰り返す
for (var i = 0; i < 8; i++){
var WindowHeight = $(window).height() - $('#top').height();
var width = $('#content-wrap').width();
var height= $('#dplayer').width() * (9 / 16) + $('#tweet-box').height();
var width = $('#content-wrap').width();
var height= $('#dplayer').width() * (9 / 16) + 136; // $('#tweet-box').height()
$('section').css('max-width',(width * WindowHeight) / height + "px" );
}
}
Expand Down
16 changes: 14 additions & 2 deletions htdocs/files/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
dataType: "json",
cache: false,
success: function(data) {
$("#watchnow").text(data["watchnow"] + '人が視聴中');
$("#watchnow").text(data["watchnow"] + '人が視聴中');
}
});
return status;
Expand All @@ -65,6 +65,18 @@
success: function(data) {

// 結果をHTMLにぶち込む

// 状態を隠しHTMLに書き出して変化してたらリロードする
if ((data['info']['status'] != $("#status").text()) && $("#status").text() != ''){
// location.reload(true);
// ストリームを読み込みし直す
var video = $('.dplayer-video-current').get(0);
video.src = 'stream/stream.m3u8';
dp.initVideo(video, 'hls');
dp.play();
}
$("#status").text(data['info']['status']);
console.log('status: ' + data['info']['status']);

if (data['info']['state'] == 'ONAir'){

Expand Down Expand Up @@ -111,7 +123,7 @@
}
});
return status;
}()),5000);
}()), 2000);

// Zenzawatchのコードより一部改変した上で使わせて頂いています
// 参考
Expand Down
22 changes: 21 additions & 1 deletion htdocs/files/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,29 @@ td {
margin-left: 8px;
}

#dplayer-box {
position: relative;
width: 100%;
height: 0;
padding-top: 56.25%;
}

#dplayer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000;
}

@media (max-width: 500px){

#dplayer-box {
height: auto;
padding-top: 0px;
}

#dplayer {
position: sticky;
position: -webkit-sticky;
Expand Down Expand Up @@ -852,7 +868,11 @@ td {
}

.chinfo {
display:inline-block;
display: inline-block;
}

#status {
display: none;
}

.subinfo {
Expand Down
1 change: 1 addition & 0 deletions htdocs/files/toastr.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions htdocs/files/toastr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 22 additions & 3 deletions htdocs/files/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ $(function(){
// 最初に表示させる
sortFileinfo('fileinfo', 1);

// トーストのオプション
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-left",
"preventDuplicates": false,
"onclick": null,
"showDuration": "200",
"hideDuration": "200",
"timeOut": "3000",
"extendedTimeOut": "1000",
"showEasing": "linear",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}

// データを取得して引数にあわせてソートする関数
function sortFileinfo(json, sortnum, flg = true){

Expand Down Expand Up @@ -152,8 +171,8 @@ $(function(){
});

// リスト更新
$('#searchfile').click(function(event){
alert('更新中です…');
$('#searchfile').click(function(event){
toastr.info('更新中です…');
$('#menu-content').removeClass('open');
$.ajax({
url: "api/searchfile.php",
Expand All @@ -166,7 +185,7 @@ $(function(){
$('#name-down').removeClass('search-find-selected');
$('#play-history').removeClass('search-find-selected');
sortFileinfo('fileinfo', 1);
alert('リストを更新しました。');
toastr.info('リストを更新しました。');
}
});
});
Expand Down
11 changes: 8 additions & 3 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
<section id="main">
<div id="content-wrap">
<div id="content">
<div id="dplayer"></div>
<script id="dplayer-script">
<div id="dplayer-box">
<div id="dplayer"></div>
<script id="dplayer-script">

const dp = new DPlayer({
container: document.getElementById('dplayer'),
Expand Down Expand Up @@ -74,7 +75,8 @@
dp.seek(1);
<?php } //括弧終了 ?>

</script>
</script>
</div>

<div id="tweet-box">
<div id="tweet-info">
Expand Down Expand Up @@ -147,6 +149,7 @@
<?php if ($ini['state'] == "ONAir"){ ?>
<div class="chinfo">
<span id="state" style="color: #007cff;">● ON Air</span>
<span id="status"></span>
<span id="channel"><?php echo $channel; ?></span>
</div>
<span class="livetime">
Expand All @@ -155,13 +158,15 @@
<?php } else if ($ini['state'] == "Offline") { ?>
<div class="chinfo">
<span id="state" style="color: gray;">● Offline</span>
<span id="status"></span>
</div>
<span class="livetime">
<span id="starttime"></span><span id="to"></span><span id="endtime"></span>
</span>
<?php } else if ($ini['state'] == "File") { ?>
<div class="chinfo">
<span id="state" style="color: #4ECDC4;">● File</span>
<span id="status"></span>
<span id="channel"><?php echo $ini['filechannel']; ?></span>
</div>
<span class="livetime"><?php echo $ini['filetime']; ?></span>
Expand Down
8 changes: 5 additions & 3 deletions htdocs/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@
<section id="main">
<div id="content-wrap">
<div id="content">
<div id="dplayer"></div>
<script id="dplayer-script">
<div id="dplayer-box">
<div id="dplayer"></div>
<script id="dplayer-script">

const dp = new DPlayer({
container: document.getElementById('dplayer'),
Expand Down Expand Up @@ -190,7 +191,8 @@
dp.seek(1);
<?php } //括弧終了 ?>

</script>
</script>
</div>
</div>

<div id="sidebar">
Expand Down

0 comments on commit c6db621

Please sign in to comment.