
您好,我正在嘗試獲取一個按鈕來將視頻時間設置為精確點。下面列出的程式碼是我到目前為止所寫的,但它不起作用。我想是因為它無法取得 document.getElementById。有人知道如何解決這個問題嗎?
\documentclass{article}
\usepackage[pdftex]{hyperref}
\usepackage[pdftex]{insdljs}
\usepackage{media9}
\begin{insDLJS}{mydljs}{some comment}
function stop(){
var vid = document.getElementById("bunny.mp4");
vid.currentTime=5;
}
\end{insDLJS}
\begin{document}
\includemedia[width=0.6\linewidth,height=0.6\linewidth,activate=pageopen,
passcontext,
transparent,
addresource=bunny.mp4,
flashvars={source=bunny.mp4}
]{}{VPlayer.swf}
\begin{Form}
\PushButton[onclick={stop();}]{5 sec}\\
\TextField[name=somefield, width=4em]{Any way to hide e.g. this text?}
\end{Form}
\end{document}ode here
答案1
JavaScript 是不是必需的。
可以使用該指令插入其他控制按鈕\mediabutton
。看看media9
手動的舉些例子。
如果您無法精確地搜尋視頻,則可能需要使用更多數量的關鍵影格重新編碼影片。
例如,每秒一個關鍵幀,使用具有相同值的ffmpeg
選項-g ...
和(幀速率):-r ...
ffmpeg -i video-in.mp4 -c:v libx264 -profile:v high -pix_fmt yuv420p -g 30 -r 30 video-out.mp4
更新: 背頁範例example-movie.mp4
帶有包中的嵌入視頻文件mwe
,使用上面列出的命令列每秒使用關鍵影格重新編碼。
串流影片範例:
\documentclass{article}
\usepackage{media9}
\parindent=0pt
\begin{document}
\includemedia[
label=videoexample,
width=16em,height=9em,
activate=pageopen,
passcontext,
transparent,
flashvars={source=https://ia800501.us.archive.org/10/items/BigBuckBunny_310/big_buck_bunny_640_512kb.mp4}
]{}{VPlayer.swf}
\mediabutton[
mediacommand=videoexample:play[(25)],
mediacommand=videoexample:pause
]{\fbox{25~s}}
\mediabutton[
mediacommand=videoexample:play[(50)],
mediacommand=videoexample:pause
]{\fbox{50~s}}
\mediabutton[
mediacommand=videoexample:play[(150)],
mediacommand=videoexample:pause
]{\fbox{150~s}}
\end{document}