FreeTubeApp / FreeTube

An Open Source YouTube app for privacy
https://freetubeapp.io/
GNU Affero General Public License v3.0
13.37k stars 825 forks source link

Sharing and Viewing a Video with Custom Start Time and End Time #883

Open tiwarys opened 3 years ago

tiwarys commented 3 years ago

I think it would be nice if you could add a feature of Sharing a Video with Custom Start Time and End Time. Currently we can share a YouTube Video with Custom Start Time but not Custom End Time with FreeTube. Moreover, if I try to view a video with Custom Start Time and End Time by searching URL in search box, video is being displayed but am not able to play it. Loading is taking long time. But if I use web browser to open a link with Custom Start Time and End Time it is working fine.

Useful links: https://www.jihosoft.com/tips/share-youtube-video-at-specific-time.html https://stackoverflow.com/questions/4661905/how-to-customize-an-end-time-for-a-youtube-video

GilgusMaximus commented 3 years ago

Hi, could you please provide an example URL for your described problem? :) Then anyone can test it and think about how to implement it.

tiwarys commented 3 years ago

For example, if we want the video to start at 02:09 and end at 03:59, then the link should be: https://www.youtube.com/embed/1jCOLYewTFc?start=129&end=239

Note: Only use web browser to open above link then only custom start time and end time is working. Even YouTube app doesn't work with custom end time.

GilgusMaximus commented 3 years ago

The problem with your link is that it is the embedded view and not the default view. FreeTube does not recognize the embedded link and thinks it is a search string.

Adding the start and end time however can be implemented. Especially the start time, since the app already employs the feature to start an already watched video back where you stopped.

This could also be done rather easily by a new contributor, or really anyone else who wants to add this to the app. We are open for PR's and happy to help if any problems occur :)

fatpowaranga commented 3 years ago

Just wanting to check, is the gist of this ticket to basically make YouTube embed links work in Freetube? If so, I think I can take a look at this.

tiwarys commented 3 years ago

@fatpowaranga Yes. Mainly it is the gist of this issue. Currently we can only share a video with custom start time in FreeTube app but we cannot share a video with custom end time. So consider implementation of sharing a video with custom end time.

fatpowaranga commented 3 years ago

@shivasagarrao I see. I'm happy to look at implementing, so you can at least share an embed link with an end time, however viewing embed links with a custom start/end may be difficult due to how the app currently strips the video ID out of the URL to find the actual video URL.

@GilgusMaximus I want to check with you to make sure what I am saying makes sense. Do you agree that sharing should be easy enough but that using an embed link with custom start/end time may be harder? At the moment going to an embed link just goes to the actual video URL rather than the embed version of the video.

tiwarys commented 3 years ago

For example, if we want the video to start at 02:09 and end at 03:59, then the link should be: https://www.youtube.com/embed/1jCOLYewTFc?start=129&end=239

Note: Only use web browser to open above link then only custom start time and end time is working. Even YouTube app doesn't work with custom end time.

@fatpowaranga I already gave an example video link in the above comments.

fatpowaranga commented 3 years ago

@shivasagarrao I understand that, what I'm saying is it may be best to split this into two jobs, as the sharing link should be easy enough, but I believe the viewing embed links in FreeTube part may be a bit harder as the normal YouTube videos do not support custom end times, only embeds.

GilgusMaximus commented 3 years ago

@fatpowaranga thanks for taking a look onto this. So I'd say that sharing a link with a custom end time should be rather easy to do as you mentioned. Only thing we need for that is a way to allow users to set the start and end time. So something like a popup or menu which allows the user to type the minute and second in would probably do it.

For the link I would use a more general approach and simply check whether the start and end parameters are set. The start works for normal links already, so it should not be too hard to add embedded links and the end time.

However I am not so sure about viewing these links though. Because even on embedded links you can simply go beyond the end time and nothing happens. It just plays on. The code to realize playback which stops at some time will need some additional logic to get the information to the Watch page, whether the link was such a shared link and where to stop playing back. So this could be hooked up similar to the already existing 'Starting Time' but needs continuous checks when to stop playback. You might be able to get an idea over at #1130. @starsep implemented some timeline related stuff as far as I have seen on a quick glance.