@@ -35,21 +35,11 @@ if (player_data.aspect_ratio) {
3535
3636var embed_url = new URL ( location ) ;
3737embed_url . searchParams . delete ( 'v' ) ;
38- short_url = location . origin + '/' + video_data . id + embed_url . search ;
38+ var short_url = location . origin + '/' + video_data . id + embed_url . search ;
3939embed_url = location . origin + '/embed/' + video_data . id + embed_url . search ;
4040
4141var save_player_pos_key = "save_player_pos" ;
4242
43- var shareOptions = {
44- socials : [ 'fbFeed' , 'tw' , 'reddit' , 'email' ] ,
45-
46- url : short_url ,
47- title : player_data . title ,
48- description : player_data . description ,
49- image : player_data . thumbnail ,
50- embedCode : "<iframe id='ivplayer' width='640' height='360' src='" + embed_url + "' style='border:none;'></iframe>"
51- }
52-
5343videojs . Vhs . xhr . beforeRequest = function ( options ) {
5444 if ( options . uri . indexOf ( 'videoplayback' ) === - 1 && options . uri . indexOf ( 'local=true' ) === - 1 ) {
5545 options . uri = options . uri + '?local=true' ;
@@ -59,6 +49,38 @@ videojs.Vhs.xhr.beforeRequest = function(options) {
5949
6050var player = videojs ( 'player' , options ) ;
6151
52+ /**
53+ * Function for add time argument to url
54+ * @param {String } url
55+ * @returns urlWithTimeArg
56+ */
57+ function addCurrentTimeToURL ( url ) {
58+ var urlUsed = new URL ( url ) ;
59+ urlUsed . searchParams . delete ( 'start' ) ;
60+ var currentTime = Math . ceil ( player . currentTime ( ) ) ;
61+ if ( currentTime > 0 )
62+ urlUsed . searchParams . set ( 't' , currentTime ) ;
63+ else
64+ if ( urlUsed . searchParams . has ( 't' ) )
65+ urlUsed . searchParams . delete ( 't' ) ;
66+ return urlUsed ;
67+ }
68+
69+ var shareOptions = {
70+ socials : [ 'fbFeed' , 'tw' , 'reddit' , 'email' ] ,
71+
72+ get url ( ) {
73+ return addCurrentTimeToURL ( short_url ) ;
74+ } ,
75+ title : player_data . title ,
76+ description : player_data . description ,
77+ image : player_data . thumbnail ,
78+ get embedCode ( ) {
79+ return "<iframe id='ivplayer' width='640' height='360' src='" +
80+ addCurrentTimeToURL ( embed_url ) + "' style='border:none;'></iframe>" ;
81+ }
82+ } ;
83+
6284const storage = ( ( ) => {
6385 try { if ( localStorage . length !== - 1 ) return localStorage ; }
6486 catch ( e ) { console . info ( 'No storage available: ' + e ) ; }
0 commit comments