Commit b7f2759f authored by 杨培's avatar 杨培

Merge remote-tracking branch 'origin/master'

parents 80675f58 dec840b7
...@@ -18,15 +18,13 @@ class AppAsset extends AssetBundle ...@@ -18,15 +18,13 @@ class AppAsset extends AssetBundle
]; ];
public $js = [ public $js = [
['common/common.js', 'position'=>View::POS_HEAD], ['common/common.js', 'position' => View::POS_HEAD],
]; ];
public $depends = [ public $depends = [
//'yii\web\YiiAsset',
//'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset' 'yii\bootstrap\BootstrapAsset'
]; ];
//定义按需加载JS方法,注意加载顺序在最后 //定义按需加载JS方法,注意加载顺序在最后
public static function addScript($view, $jsfile) public static function addScript($view, $jsfile)
{ {
...@@ -41,14 +39,31 @@ class AppAsset extends AssetBundle ...@@ -41,14 +39,31 @@ class AppAsset extends AssetBundle
$view->registerCssFile($cssfile, [AppAsset::className(), 'depends' => 'frontend\assets\AppAsset']); $view->registerCssFile($cssfile, [AppAsset::className(), 'depends' => 'frontend\assets\AppAsset']);
} }
/**
* $path 为相对baseUrl 的相对路径
*
* 生成带时间戳的图片地址
* @param $path
* @return string
*/
public static function getStaticUrl($path)
{
$path = '@web/assets/' . $path;
$path = self::appendTimestamp($path);
return Yii::getAlias($path);
}
public static function appendTimestamp($url) public static function appendTimestamp($url)
{ {
if (Yii::$app->assetManager->appendTimestamp && strncmp($url, '@web/', 5) === 0) { if (Yii::$app->assetManager->appendTimestamp && strncmp($url, '@web/', 5) === 0) {
$fileToCacheBust = Yii::getAlias(str_replace('@web', '@webroot', $url)); $fileToCacheBust = Yii::getAlias(str_replace('@web', '@webroot', $url));
if (($timestamp = @filemtime("$fileToCacheBust")) > 0) if (($timestamp = filemtime("$fileToCacheBust")) > 0)
$url .= "?v={$timestamp}"; $url .= "?v={$timestamp}";
} }
return $url; return $url;
} }
} }
...@@ -6,6 +6,19 @@ ...@@ -6,6 +6,19 @@
?> ?>
<h1>home/index</h1> <h1>home/index</h1>
<p>
<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="auto" width="640" height="264"
poster="http://dev.qdn.pp.cc/object/test-thumb1.jpg"
data-setup='{"example_option":true,"autoplay":false,"language":"zh-CN"}'>
<source src="http://dev.qdn.pp.cc/object/test-3.mp4" type="video/mp4"/>
</video>
</p>
<p> <p>
You may change the content of this page by modifying You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>. the file <code><?= __FILE__; ?></code>.
......
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
* Date: 2016/9/27 * Date: 2016/9/27
* Time: 下午4:16 * Time: 下午4:16
*/ */
\frontend\assets\AppAsset::addScript($this,'@web/assets/user_center_info.js') \frontend\assets\AppAsset::addScript($this, '@web/assets/user_center_info.js')
?> ?>
<h1>user-center/info</h1> <h1>user-center/info</h1>
<img
src="<?php echo Yii::$app->user->identity->avatar === '' ? \frontend\assets\AppAsset::getStaticUrl('img/avatar.jpg') : Yii::$app->user->identity->avatar ?>">
<p> <p>
You may change the content of this page by modifying You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>. the file <code><?= __FILE__; ?></code>.
......
...@@ -3,6 +3,16 @@ ...@@ -3,6 +3,16 @@
*/ */
require('expose?videojs!../libs/videojs/video.js'); require('expose?videojs!../libs/videojs/video.js');
require('../libs/videojs/video-js.css'); require('../libs/videojs/video-js.css');
require('../libs/videojs/lang/zh-CN.js');
// console.log(videojs); // console.log(videojs);
// layer.msg('home/index'); // layer.msg('home/index');
videojs.options.flash.swf =''; videojs.options.flash.swf = __CDN_URL__ + 'assets/videojs/video-js.swf';
\ No newline at end of file window.VIDEOJS_NO_BASE_THEME = true;
videojs("example_video_1").ready(function () {
var myPlayer = this;
// EXAMPLE: Start playing the video.
myPlayer.play();
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
videojs.addLanguage("zh-CN",{
"Play": "播放",
"Pause": "暂停",
"Current Time": "当前时间",
"Duration Time": "时长",
"Remaining Time": "剩余时间",
"Stream Type": "媒体流类型",
"LIVE": "直播",
"Loaded": "加载完毕",
"Progress": "进度",
"Fullscreen": "全屏",
"Non-Fullscreen": "退出全屏",
"Mute": "静音",
"Unmute": "取消静音",
"Playback Rate": "播放码率",
"Subtitles": "字幕",
"subtitles off": "字幕关闭",
"Captions": "内嵌字幕",
"captions off": "内嵌字幕关闭",
"Chapters": "节目段落",
"You aborted the media playback": "视频播放被终止",
"A network error caused the media download to fail part-way.": "网络错误导致视频下载中途失败。",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "视频因格式不支持或者服务器或网络的问题无法加载。",
"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "由于视频文件损坏或是该视频使用了你的浏览器不支持的功能,播放终止。",
"No compatible source was found for this media.": "无法找到此视频兼容的源。",
"The media is encrypted and we do not have the keys to decrypt it.": "视频已加密,无法解密。"
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment