V5.7 YouTube Block, Using start/end
Permalinkhttps://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?

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? ;)
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.
$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
Then what could be causing the data to not be stored?
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='
$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.
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.