[TW5] Source attribute for the video html tag

76 views
Skip to first unread message

FrD

unread,
Jun 25, 2015, 7:18:46 AM6/25/15
to tiddl...@googlegroups.com
Hi,

I'm trying to built a TW5 to be used as a front-end for various teaching videos.
The videos are extracted from various sources, mostly DVDs and Youtube videos. They are all on the local disk.
One DVD is split into several mp4 videos, all stored in the same directory. So I have one directory per DVD, and some more for the videos I downloaded from Youtube.

In the TW I plan to have one tiddler for each video. I've built a template to be transcluded in each video tiddler.

The content of a video tiddler is : {{||VideoTemplate}}

It has two fields (and some others but not relevant here) :
* "origin" : the source of the video, for instance "DVDSubject1"
* "filename" : the name of the video file, for instance "subject1part1.mp4"

The path to the video directory is in a dictionary tiddler (VideoPathDictionary) :

DVDSubject1:RelativePathToVideoDirectoryDVDSubject1
DVDSubject2:RelativePathToVideoDirectoryDVDSubject2
YTSubject5:RelativePathToVideoDirectoryYoutubeSubject5

One example of relative path is : ../../Videos/DVDSubject1

The template tiddler contains :

\define videofullfilename()
   {{VideoPathDictionary##$(origin)$}}$(filename)$
\end

\define videocall()
        <video width=480 height=384 controls="controls">
            <source src=$(mySource)$/>
        </video>
\end

<$set name="origin" value={{!!origin}}>
    <$set name="filename" value={{!!filename}}>
        <$set name="mySource" value=$(videofullfilename)$>
        <<videocall>>
        </$set>
    </$set>
</$set>

I've tried many combinations but no way to get the right filename for the source attribute !

Could someone help ?

I've used successfully that code structure to set the width and height of the video, with two dictionary tiddlers : VideoWidthDictionary and VideoHeightDictionary, but I can't figure out why it doesn't work with the source attribute.

Thanks

FrD


FrD

unread,
Jun 25, 2015, 9:39:40 AM6/25/15
to tiddl...@googlegroups.com


Le jeudi 25 juin 2015 13:18:46 UTC+2, FrD a écrit :
Hi,


...
One example of relative path is : ../../Videos/DVDSubject1

In fact the correct path is : ../../Videos/DVDSubject1/
 

The template tiddler contains :


...
 
Thanks

FrD



Some details : It looks like the source attribute only contains the part of the path coming from the dictionary tiddler. The file name is not appended.
On way I can see this is by putting the full filename in the dictionary tiddler (VideoPathDictionary), something like :

../../Videos/DVDSubject1/subject1part1.mp4

In this case the video is displayed !

FrD

BJ

unread,
Jun 25, 2015, 10:21:39 AM6/25/15
to tiddl...@googlegroups.com
Hi
try
<<videofullfilename>> in place of $(videofullfilename)$

cheers

BJ

FrD

unread,
Jun 25, 2015, 10:32:59 AM6/25/15
to tiddl...@googlegroups.com
Hi BJ,

Thanks for your suggestion.
I've already tried it ; it doesn't work.

What's stange is that if you put in the VideoTemplate

<<videofullfilename>>
or <<mySource>>

a line before
<<videocall>>

you can see that the variable holds the correct value. But in the source attribute the value of the variable seems to be restrictred to the part coming from the dictionary tiddler and does not include the $(filename)$ value.

FrD

BJ

unread,
Jun 25, 2015, 6:42:09 PM6/25/15
to tiddl...@googlegroups.com
Unfortunately there is a limitation on using macros within parameters (they perform simple substitutions instead of what you would expect)

try


\define videocall()
        <video width=480 height=384 controls="controls">
            <source src= {{VideoPathDictionary##$(origin)$}}$(filename)$/>
        </video>
\end

<$set name="origin" value={{!!origin}}>
    <$set name="filename" value={{!!filename}}>
        <<videocall>>
    </$set>
</$set>

BJ

On Thursday, June 25, 2015 at 12:18:46 PM UTC+1, FrD wrote:

FrD

unread,
Jun 26, 2015, 2:41:01 AM6/26/15
to tiddl...@googlegroups.com
Hi BJ,

I get the same result : src seems to contain only the part {{VideoPathDictionary##$(origin)$}}. It looks like $(filename)$ is discarded !

I made another experiment.
I put a "path" field in the video tiddler ; path=../../Videos/DVDSubject1/
I modified the template :


\define videocall()
        <video width=480 height=384 controls="controls">
<source src= "$(path)$$(filename)$"/>          <---- with quotes !
        </video>
\end

<$set name="path" value={{!!path}}>

    <$set name="filename" value={{!!filename}}>
            <<videocall>>
    </$set>
</$set>

This time it works as expected !
But it's not what I intended to do, as I wanted to centralize the paths in a dictionary tiddler and not put them in each tiddler.

Anyway thanks for your proposal

FrD

BJ

unread,
Jun 26, 2015, 5:32:15 AM6/26/15
to tiddl...@googlegroups.com

I think this should work

\define videocall1()
        <$set name="mySource" value={{VideoPathDictionary##$(origin)$}}>
        <<videocall>>
        </$set>

\end

\define videocall()
        <video width=480 height=384 controls="controls">
            <source src= "$(mySource)$$(filename)$"/>

        </video>
\end

<$set name="origin" value={{!!origin}}>
    <$set name="filename" value={{!!filename}}>
        <<videocall1>>
    </$set>
</$set>

cheers BJ

FrD

unread,
Jun 26, 2015, 5:55:24 AM6/26/15
to tiddl...@googlegroups.com
Hi BJ,

Yes it works !!!
I was about to give up and you saved my day.

Thank you very very much!!!

FrD


Le vendredi 26 juin 2015 11:32:15 UTC+2, BJ a écrit :

I think this should work

...

cheers BJ


Reply all
Reply to author
Forward
0 new messages