V5.7 YouTube Block, Using start/end
Permalink
I haven't been able to use the YouTube block to play a video using the start and end parameters as shown in the example below.
https://www.youtube.com/v/DMrpXKG_CS8?start=161&end=170...
Is it possible to use a portion of a YouTube video like this or by some other method?
https://www.youtube.com/v/DMrpXKG_CS8?start=161&end=170...
Is it possible to use a portion of a YouTube video like this or by some other method?
You could override the core YouTube block to add Start and End parameters and then pass those in to the iframe in the view.
Ok, I want to give this a try even though I'm a newb. First let me see if I understand the procedure.
1. Copy the concrete/blocks/youtube folder to application/blocks/youtube
2. Edit db.xml to add the start (and end) fields
<field name="start" type="integer">
</unsigned>
</field>
3. Edit the view.php file to read these parameters from the db and add them to the params array.
if (isset($start) && $start > 0) {
$params[] = 'start=' . $start;
}
4. Edit the form_setup_html.php file
<div class="ccm-tab-content" id="ccm-tab-content-settings">
<fieldset>
<legend><?php echo t('Playback Options'); ?></legend>
:
:
<div class="form-group">
<label class='control-label'><?php echo t('Start Seconds:') ?></label>
<input type="text" name="start" value="<?php echo $start ?>" class="form-control">
</div>
</fieldset>
</div>
Am I on the right track or delusional? ;)
1. Copy the concrete/blocks/youtube folder to application/blocks/youtube
2. Edit db.xml to add the start (and end) fields
<field name="start" type="integer">
</unsigned>
</field>
3. Edit the view.php file to read these parameters from the db and add them to the params array.
if (isset($start) && $start > 0) {
$params[] = 'start=' . $start;
}
4. Edit the form_setup_html.php file
<div class="ccm-tab-content" id="ccm-tab-content-settings">
<fieldset>
<legend><?php echo t('Playback Options'); ?></legend>
:
:
<div class="form-group">
<label class='control-label'><?php echo t('Start Seconds:') ?></label>
<input type="text" name="start" value="<?php echo $start ?>" class="form-control">
</div>
</fieldset>
</div>
Am I on the right track or delusional? ;)
It sounds like you're doing great, make sure you update the Namespace in the controller to be application instead of Concrete or you will get errors.
Once you're done with your updates you'll also want to go into the Block Types in the Dashboard and "Refresh" the YouTube block to get the db.xml updates put in.
Once you're done with your updates you'll also want to go into the Block Types in the Dashboard and "Refresh" the YouTube block to get the db.xml updates put in.
if (isset($start) && $start > 0) {
$params[] = 'start=' . $start;
}
I'm new to PHP. What's the deal with the dot. I noticed some other params without.
$params[] = 'start=' . $start;
[edit-1]
Ok, got it all done. Edit block form now has the start and end fields. However, video does not start and end at the specified time frames. Is there a way to look at the URL string that gets generated. Tried Chrome's InspectElement and just get an inner wrapper div.
[edit-2]
The problem is that the data entered into the start and end fields is not being saved. I enter the data and click save. When I go back into edit the fields are blank again. Any ideas
$params[] = 'start=' . $start;
}
I'm new to PHP. What's the deal with the dot. I noticed some other params without.
$params[] = 'start=' . $start;
[edit-1]
Ok, got it all done. Edit block form now has the start and end fields. However, video does not start and end at the specified time frames. Is there a way to look at the URL string that gets generated. Tried Chrome's InspectElement and just get an inner wrapper div.
[edit-2]
The problem is that the data entered into the start and end fields is not being saved. I enter the data and click save. When I go back into edit the fields are blank again. Any ideas
That is how you combine a string and a variable, so in your case you would want to do 'start='.$start because you want to have that in your query string for the YouTube URL.
Ok, so then 'Start=' . $Start should be correct right?
Then what could be causing the data to not be stored?
Then what could be causing the data to not be stored?
1) Are the fields in the database?
2) Did you update the save function in the controller to store your values?
Be mindful of case as well, if you have used start (all lower) in your db.xml you will need to use $start as your variable, if you have used Start you will need you use $Start, and in the URL string it should be 'start='
2) Did you update the save function in the controller to store your values?
Be mindful of case as well, if you have used start (all lower) in your db.xml you will need to use $start as your variable, if you have used Start you will need you use $Start, and in the URL string it should be 'start='
Forgotten step ... edit controller.php
$args['start'] = $data['start'];
$args['end'] = $data['end'];
When I did this I got it to work. Data is stored and retrieved from the DB, and video begins and ends at specified start and end times the first time after page load. On subsequent plays entire video plays. It would appear that the url parameters need to be refreshed but I have no idea where/how that should be done. Initially it's done in view.php , is there something that runs after the video completes?
The other thing I'd like to do is use the a frame near the start time as the thumbnail. Not really a C5 thing and the suggestions I've found on the net don't seem to be appealing.
Thank you so ,much hutman for helping me learn how to do this. If I can get this last thing working (i.e. subsequent plays with correct start and end times) I would like to contribute it to the community.
$args['start'] = $data['start'];
$args['end'] = $data['end'];
When I did this I got it to work. Data is stored and retrieved from the DB, and video begins and ends at specified start and end times the first time after page load. On subsequent plays entire video plays. It would appear that the url parameters need to be refreshed but I have no idea where/how that should be done. Initially it's done in view.php , is there something that runs after the video completes?
The other thing I'd like to do is use the a frame near the start time as the thumbnail. Not really a C5 thing and the suggestions I've found on the net don't seem to be appealing.
Thank you so ,much hutman for helping me learn how to do this. If I can get this last thing working (i.e. subsequent plays with correct start and end times) I would like to contribute it to the community.
Unfortunately now you're getting into more of the YouTube stuff and less of the C5 stuff, I can't help with the thumbnail or the second play, because it loads in an iframe on the page I don't know what exactly happens on the YouTube side after it plays once. I can tell you that the view.php only gets called on page load and after you edit the block though.
I did some experiments and it appears that the youtube player honors the start and end parameters only the first time. So I'm going to stop at this point.
Again hutman, thank you very much for your help. I am very happy to have learned a bit more about C5 and look forward to learning more as time goes by.
Again hutman, thank you very much for your help. I am very happy to have learned a bit more about C5 and look forward to learning more as time goes by.