blob: b6cea33596c2da112ebd70703dd5618334dac978 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
%%
%% This is file `lwarp-common-multimedia.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lwarp.dtx (with options: `common-multimedia')
%% This is a generated file.
%% Copyright 2016-2019 Brian Dunn
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
\ProvidesPackage{lwarp-common-multimedia}[2019/04/22]
\RequirePackage{xkeyval}
\define@key{LWR@multimedia}{width}{\setlength{\LWR@multimedia@width}{#1}}
\define@key{LWR@multimedia}{height}{\setlength{\LWR@multimedia@height}{#1}}
\define@key{LWR@multimedia}{totalheight}{\setlength{\LWR@multimedia@height}{#1}}
\newlength{\LWR@multimedia@width}
\newlength{\LWR@multimedia@height}
\newlength{\LWR@multimedia@maxdimension}
\newcommand*{\LWR@multimedia@printsize}{%
\setlength{\LWR@multimedia@maxdimension}{%
\maxof%
{\linewidth}%
{\maxof{\LWR@multimedia@width}{\LWR@multimedia@height}}%
}%
\setlength{\LWR@multimedia@maxdimension}{1.1\LWR@multimedia@maxdimension}%
\ifdimgreater{\LWR@multimedia@width}{0pt}{%
width:%
\LWR@printpercentlength%
{\LWR@multimedia@width}%
{\LWR@multimedia@maxdimension}vmin ; % space
}{}%
\ifdimgreater{\LWR@multimedia@height}{0pt}{%
height:%
\LWR@printpercentlength%
{\LWR@multimedia@height}%
{\LWR@multimedia@maxdimension}vmin ; % space
}{}%
}
\newcommand*{\LWR@multimedia@fileAV}[4]{%
\filename@parse{#2}%
\IfFileExists{#2}{%
\begin{BlockClass}[\LWR@multimedia@printsize\ margin:auto]{AVviewport}
\LWR@stoppars
\LWR@htmltag{%
#3\ % space
width=\textquotedbl{}100\%\textquotedbl\ % space
height=\textquotedbl{}100\%\textquotedbl\ % space
controls%
}\LWR@orignewline
\LWR@htmltag{%
source % space
src=\textquotedbl%
\@filef@und\unskip\textquotedbl\ % space
type=\textquotedbl{}#4\textquotedbl}
\LWR@startpars
\href{\@filef@und}{#1}
\LWR@stoppars
\LWR@htmltag{/#3}\LWR@orignewline
\end{BlockClass}
}{%
\PackageError{lwarp-common-multimedia}
{File '#2' not found}
{Perhaps an incorrect path?}
}%
}
\newcommand*{\LWR@multimedia@httpAV}[4]{%
\begin{BlockClass}[\LWR@multimedia@printsize\ margin:auto]{AVviewport}
\LWR@stoppars
\LWR@htmltag{%
#3\ % space
width=\textquotedbl{}100\%\textquotedbl\ % space
height=\textquotedbl{}100\%\textquotedbl\ controls}\LWR@orignewline
\LWR@htmltag{%
source % space
src=\textquotedbl#2\textquotedbl\ % space
type=\textquotedbl#4\textquotedbl}
\LWR@startpars
\href{#2}{#1}
\LWR@stoppars
\LWR@htmltag{/#3}\LWR@orignewline
\end{BlockClass}
}
\newcommand*{\LWR@multimedia@AV}[4]{%
\IfBeginWith{#2}{http}%
{\LWR@multimedia@httpAV{#1}{#2}{#3}{#4}}%
{%
\IfBeginWith{#2}{HTTP}%
{\LWR@multimedia@httpAV{#1}{#2}{#3}{#4}}%
{\LWR@multimedia@fileAV{#1}{#2}{#3}{#4}}%
}%
}
\newcommand*{\LWR@multimedia@embed}[3]{%
\begin{BlockClass}[width:100\%]{AVviewport}%
\LWR@stoppars
\LWR@htmltag{%
embed % space
\ifblank{#3}{}{type=\textquotedbl#3\textquotedbl\ }%
style=\textquotedbl\LWR@multimedia@printsize\ margin:auto\textquotedbl\ % space
src=\textquotedbl#2\textquotedbl\ % space
}%
\LWR@startpars
\end{BlockClass}
}
\newcommand*{\LWR@multimedia@percenterror}{%
\PackageError{lwarp-media9}
{%
Do not use a percent comment
between\MessageBreak
\protect\includemedia\space arguments%
}
{Percent is changed to a regular character to allow its use inside a URL.}
}
\newcommand*{\LWR@multimediab}[3][]{%
\if#1\@percentchar\LWR@multimedia@percenterror\fi%
\if#2\@percentchar\LWR@multimedia@percenterror\fi%
\if#3\@percentchar\LWR@multimedia@percenterror\fi%
\setlength{\LWR@multimedia@width}{0pt}%
\setlength{\LWR@multimedia@height}{0pt}%
\setkeys*{LWR@multimedia}{#1}%
\IfEndWith{#3}{.mp4}{\LWR@multimedia@AV{#2}{#3}{video}{video/mp4}}{%
\IfEndWith{#3}{.MP4}{\LWR@multimedia@AV{#2}{#3}{video}{video/mp4}}{%
\IfEndWith{#3}{.mp3}{\LWR@multimedia@AV{#2}{#3}{audio}{audio/mpeg}}{%
\IfEndWith{#3}{.MP3}{\LWR@multimedia@AV{#2}{#3}{audio}{audio/mpeg}}{%
\IfBeginWith{#3}{http}{\LWR@multimedia@embed{#2}{#3}{}}{%
\IfBeginWith{#3}{HTTP}{\LWR@multimedia@embed{#2}{#3}{}}{%
\IfBeginWith{#3}{ftp}{\LWR@multimedia@embed{#2}{#3}{}}{%
\IfBeginWith{#3}{FTP}{\LWR@multimedia@embed{#2}{#3}{}}{%
\href{#3}{#2}% unknown format
}}}}}}}}%
\endgroup%
}
\newrobustcmd*{\LWR@multimedia}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@multimediab%
}
\endinput
%%
%% End of file `lwarp-common-multimedia.sty'.
|