%%
%% 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-2022 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]{%
\IfFileExists{#2}{% also sets \@filef@und
\StrSubstitute[100]{\@filef@und}{"}{}[\LWR@parsedfilename]%
    \ifstrequal{#3}{audio}{%
        \begin{BlockClass}{AVviewport}
    }{%
        \begin{BlockClass}[\LWR@multimedia@printsize\ margin:auto]{AVviewport}
    }
    \LWR@stoppars
    \LWR@htmltag{%
        #3\ % space
        \ifstrequal{#3}{audio}{}{%
            width=\textquotedbl{}100\%\textquotedbl\ % space
            height=\textquotedbl{}100\%\textquotedbl\ % space
        }%
        controls%
    }\LWR@orignewline
    \LWR@htmltag{%
        source % space
        src=\textquotedbl%
        \LWR@parsedfilename\unskip\textquotedbl\ % space
        type=\textquotedbl{}#4\textquotedbl}
    \LWR@startpars
    \LWR@href{\LWR@parsedfilename}{#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]{%
    \ifstrequal{#3}{audio}{%
        \begin{BlockClass}{AVviewport}
    }{%
        \begin{BlockClass}[\LWR@multimedia@printsize\ margin:auto]{AVviewport}
    }
    \LWR@stoppars
    \LWR@htmltag{%
        #3\ % space
        \ifstrequal{#3}{audio}{}{%
            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
    \LWR@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\MessageBreak
        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%
    \LWR@stoppars%
    \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}{}}{%
        \LWR@href{#3}{#2}% unknown format
    }}}}}}}}%
    \LWR@startpars%
    \endgroup%
}
\newrobustcmd*{\LWR@multimedia}{%
    \begingroup%
    \LWR@linkmediacatcodes%
    \LWR@multimediab%
}
\endinput
%%
%% End of file `lwarp-common-multimedia.sty'.
