Thank you TiddlyTitch, EricShulman, and digitalap3 for your replies!
Itâs great to get a reply from you Eric, I remember your tools from years back when I first started tinkering with tiddly wiki! I must be doing something wrong. I tried your code, and I can see the frame and the buttons when I put the code into a tiddler, but the video doesnât load for me. Is there something I missed?
I also tried to follow TiddlyTitchâs suggestion, with some success, but I have come stuck.
First I created a tiddler called videospeed with the tag $:/tags/RawMarkup and the type text/html and the following content:
<div>
<button onclick="changePlaybackRate(0.5)">0.5x</button>
<button onclick="changePlaybackRate(1)">1x</button>
<button onclick="changePlaybackRate(1.5)">1.5x</button>
<button onclick="changePlaybackRate(2)">2x</button>
</div>
<script>
function changePlaybackRate(rate) {
const video = document.getElementById('myVideo');
video.playbackRate = rate;
}
</script>
Then I created a normal tiddler to view the video called video_tiddler. I want to be able to select between different videos, so the tiddler needs to be refreshed each time I make a change which is why I have the checkbox. Here is the content of video_tiddler.
<$select tiddler=video_tiddler field=currentvideo>
<option value='file1.mp4'> video 1 </option>
<option value='file2.mp4'> video 2 </option>
</$select>
<$checkbox tiddler=video_tiddler field=showvideo checked=y unchecked=n default=n>Show video</$checkbox>
<$list filter='[{video_tiddler!!showvideo}match[y]]'>
<video id="myVideo" controls>
<source src={{video_tiddler!!currentvideo}} type="video/mp4">
</video>
</$list>
Then I did a save and reload of the wiki for the changes to take effect.
The playback rate buttons now appear at the very bottom of the wiki.
The speed of playback of a video within the video_tiddler wiki does change when I press one of the buttons. And when I select a different video, and refresh the tiddler by checking and unchecking the âShow videoâ checkbox, the playback rate buttons are also able to change the speed of the newly selected video that is being displayed.
So, some success!
However, this is not ideal, as the buttons are always at the bottom of the page rather than in the tiddler where the video is playing.
To be able to place the buttons where I want, I tried the following:
I removed the following buttons code from videospeed ( the $:/tags/RawMarkup tagged tiddler):
<div>
<button onclick="changePlaybackRate(0.5)">0.5x</button>
<button onclick="changePlaybackRate(1)">1x</button>
<button onclick="changePlaybackRate(1.5)">1.5x</button>
<button onclick="changePlaybackRate(2)">2x</button>
</div>
leaving just the following in the $:/tags/RawMarkup tagged tiddler:
<script>
function changePlaybackRate(rate) {
const video = document.getElementById('myVideo');
video.playbackRate = rate;
}
</script>
Then I put the buttons code that I had just removed from the $:/tags/RawMarkup tagged tiddler into the video_tiddler. And then saved and reloaded the wiki.
However, although the buttons are now in the desired place, they no longer work in changing the playback speed of the current video.
If anyone has suggestions to get this working either following TiddlyTitchâs $:/tags/RawMarkup idea (as I have tried above), or following Ericâs IFRAME approach, or indeed digitalap3âs suggestion, I would be very grateful!
And I think it could also be useful in general for users who are not expert coders to know how to incorporate javascript code that seems to work fine outside of Tiddlywiki. (Because itâs the kind of thing we non-expert users will do: ask AI to make some simple html/javascript code, and then try and paste it into a tiddler).