yii2吧 关注:132贴子:179
  • 12回复贴,共1

基于yii2开发小站视频区(video zone)

只看楼主收藏回复

😂先占坑


来自iPhone客户端1楼2016-05-15 14:53回复
    需要实现的功能:
    1.视频信息表管理(验证用户,是否有权增删查改)
    2.前端视频库显示、播放与互动(videoplayer使用Video++智能互动视频播放器)
    😂


    来自iPhone客户端2楼2016-05-15 15:13
    收起回复
      今晚应该可以更新填坑了!|( ̄3 ̄)|


      来自iPhone客户端3楼2016-05-19 18:28
      回复


        来自iPhone客户端4楼2016-05-20 00:08
        回复
          😂效果如上
          填坑开始……


          来自iPhone客户端5楼2016-05-20 00:09
          回复
            SET FOREIGN_KEY_CHECKS = 0;
            DROP TABLE IF EXISTS `vjj`;
            CREATE TABLE `vjj` (
            `jjid` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增长序号,唯一',
            `jj` varchar(32) NOT NULL COMMENT '视频长序号,唯一',
            `iszhutab1` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否关联zhutab1表,若真,则关联,vjj.jj=zhutab1.ss,视频基本信息对应;否则,vjj表“独立”',
            `Iva` varchar(255) NOT NULL COMMENT '父容器id或者父容器DOM对象',
            `appkey` varchar(32) NOT NULL DEFAULT 'Ny5TpG1Tg' COMMENT '默认留空即可',
            `live` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是直播流,默认为false',
            `video` varchar(255) NOT NULL COMMENT '播放地址或者资源地址,必填,若已关联zhutab1表,此处可留空,vjj.video=zhutab1.FileUrl|PlayUrl^',
            `title` varchar(255) NOT NULL COMMENT '视频标题,若关联zhutab1,此处vjj.title=zhutab1.sName',
            `cover` varchar(255) NOT NULL COMMENT '选填,视频封面url',
            `videoStartPrefixSeconds` int(11) NOT NULL DEFAULT '0' COMMENT '选填,跳过片头,默认为0',
            `videoEndPrefixSeconds` int(11) NOT NULL DEFAULT '0' COMMENT '选填,跳过片尾,默认为0',
            `skinSelect` tinyint(1) NOT NULL DEFAULT '0' COMMENT '选填,播放器皮肤,可选0、1、2,默认为0',
            `autoplay` tinyint(1) NOT NULL DEFAULT '0' COMMENT '选填,是否自动播放,默认为false',
            `rightHand` tinyint(1) NOT NULL DEFAULT '0' COMMENT '选填,是否开启右键菜单,默认为false',
            `autoFormat` tinyint(1) NOT NULL DEFAULT '0' COMMENT '选填,是否自动选择最高清晰度,默认为false',
            `bubble` tinyint(1) NOT NULL DEFAULT '1' COMMENT '选填,是否开启云泡功能,默认为true',
            `jumpStep` int(11) NOT NULL DEFAULT '10' COMMENT '选填,左右方向键快退快进的时间',
            `tagTrack` tinyint(1) NOT NULL DEFAULT '0' COMMENT '选填,云链是否跟踪,默认为false',
            `tagShow` tinyint(1) NOT NULL DEFAULT '0' COMMENT '选填,云链是否显示,默认为false',
            `tagDuration` int(11) NOT NULL DEFAULT '5' COMMENT '选填,云链显示时间,默认为5秒',
            `tagFontSize` int(11) NOT NULL DEFAULT '16' COMMENT '选填,云链文字大小,默认为16像素',
            `uper` varchar(32) NOT NULL COMMENT '上传者',
            `uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '上传时间,系统自动生成',
            `otherinfo` varchar(255) DEFAULT NULL COMMENT '其他信息,备用字段',
            PRIMARY KEY (`jjid`)
            ) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8 COMMENT='用来存储“Video++”详细播放设置及播放信息';
            SET FOREIGN_KEY_CHECKS = 1;


            7楼2016-05-20 12:16
            回复
              `appkey` varchar(32) NOT NULL DEFAULT
              【醒目】请把上面appkey字段的默认值设置为你自己的。


              8楼2016-05-20 12:19
              回复
                <?php
                namespace app\controllers;
                use Yii;
                use app\models\Vjj;
                use app\models\VjjSearch;
                use yii\web\Controller;
                use yii\web\NotFoundHttpException;
                use yii\filters\VerbFilter;
                /**
                * VjjController implements the CRUD actions for Vjj model.
                */
                class VjjController extends Controller
                {
                /**
                * @inheritdoc
                */
                public function behaviors()
                {
                return [
                'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                'delete' => ['POST'],
                ],
                ],
                ];
                }
                /**
                * Lists all Vjj models.
                * @return mixed
                */
                public function actionIndex()
                {
                $searchModel = new VjjSearch();
                $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
                return $this->render('index', [
                'searchModel' => $searchModel,
                'dataProvider' => $dataProvider,
                ]);
                }
                /**
                * Displays a single Vjj model.
                * @param integer $id
                * @return mixed
                */
                public function actionView($id)
                {
                return $this->render('view', [
                'model' => $this->findModel($id),
                ]);
                }
                /**
                * Creates a new Vjj model.
                * If creation is successful, the browser will be redirected to the 'view' page.
                * @return mixed
                */
                public function actionCreate()
                {
                $model = new Vjj();
                $model->scenario = 'create';
                if ($model->load(Yii::$app->request->post()) && $model->save()) {
                return $this->redirect(['view', 'id' => $model->jjid]);
                } else {
                return $this->render('create', [
                'model' => $model,
                ]);
                }
                }
                /**
                * Updates an existing Vjj model.
                * If update is successful, the browser will be redirected to the 'view' page.
                * @param integer $id
                * @return mixed
                */
                public function actionUpdate($id)
                {
                $model = $this->findModel($id);
                $model->scenario = 'update';
                if ($model->load(Yii::$app->request->post()) && $model->save()) {
                return $this->redirect(['view', 'id' => $model->jjid]);
                } else {
                return $this->render('update', [
                'model' => $model,
                ]);
                }
                }
                /**
                * Deletes an existing Vjj model.
                * If deletion is successful, the browser will be redirected to the 'index' page.
                * @param integer $id
                * @return mixed
                */
                public function actionDelete($id)
                {
                $this->findModel($id)->delete();
                return $this->redirect(['index']);
                }
                /**
                * Finds the Vjj model based on its primary key value.
                * If the model is not found, a 404 HTTP exception will be thrown.
                * @param integer $id
                * @return Vjj the loaded model
                * @throws NotFoundHttpException if the model cannot be found
                */
                protected function findModel($id)
                {
                if (($model = Vjj::findOne($id)) !== null) {
                return $model;
                } else {
                throw new NotFoundHttpException('The requested page does not exist.');
                }
                }
                }
                VjjController.php


                9楼2016-05-20 12:28
                回复
                  <?php
                  namespace app\models;
                  use Yii;
                  /**
                  * This is the model class for table "vjj".
                  *
                  * @property integer $jjid
                  * @property string $jj
                  * @property integer $iszhutab1
                  * @property string $Iva
                  * @property string $appkey
                  * @property integer $live
                  * @property string $video
                  * @property string $title
                  * @property string $cover
                  * @property integer $videoStartPrefixSeconds
                  * @property integer $videoEndPrefixSeconds
                  * @property integer $skinSelect
                  * @property integer $autoplay
                  * @property integer $rightHand
                  * @property integer $autoFormat
                  * @property integer $bubble
                  * @property integer $jumpStep
                  * @property integer $tagTrack
                  * @property integer $tagShow
                  * @property integer $tagDuration
                  * @property integer $tagFontSize
                  * @property string $uper
                  * @property string $uptime
                  * @property string $otherinfo
                  */
                  class Vjj extends \yii\db\ActiveRecord
                  {
                  /**
                  * @inheritdoc
                  */
                  public static function tableName()
                  {
                  return 'vjj';
                  }
                  public function scenarios()
                  {
                  return [
                  'create' => ['jj', 'iszhutab1', 'Iva', 'appkey', 'live', 'video', 'title', 'cover', 'videoStartPrefixSeconds', 'videoEndPrefixSeconds', 'skinSelect', 'autoplay', 'rightHand', 'autoFormat', 'bubble', 'jumpStep', 'tagTrack', 'tagShow', 'tagDuration', 'tagFontSize', 'uper', 'uptime', 'otherinfo'],
                  'update' => ['jj', 'iszhutab1', 'Iva', 'appkey', 'live', 'video', 'title', 'cover', 'videoStartPrefixSeconds', 'videoEndPrefixSeconds', 'skinSelect', 'autoplay', 'rightHand', 'autoFormat', 'bubble', 'jumpStep', 'tagTrack', 'tagShow', 'tagDuration', 'tagFontSize', 'uper', 'uptime', 'otherinfo'],
                  ];
                  }
                  /**
                  * @inheritdoc
                  */
                  public function rules()
                  {
                  return [
                  [['iszhutab1', 'live', 'videoStartPrefixSeconds', 'videoEndPrefixSeconds', 'skinSelect', 'autoplay', 'rightHand', 'autoFormat', 'bubble', 'jumpStep', 'tagTrack', 'tagShow', 'tagDuration', 'tagFontSize'], 'integer', 'min' => 0],
                  [['iszhutab1', 'live', 'autoplay', 'rightHand', 'autoFormat', 'bubble', 'tagTrack', 'tagShow'], 'integer', 'max' => 1],
                  ['skinSelect', 'in', 'range' => [0, 1, 2]],
                  ['tagFontSize', 'integer', 'min' => 8, 'max' => 72],
                  [['jj', 'video', 'title', 'uper'], 'required'],
                  [['uptime'], 'safe'],
                  ['jj', 'string', 'min' => 32, 'tooShort' => '请输入32位字符串(需全局唯一,支持中文,所以大胆个性化选择)'],
                  ['jj', 'unique', 'message' => '后端验证错误:唯一识别码已在视频库中存在,请重新选择!', 'on' => ['create', 'update']],
                  [['jj', 'appkey', 'uper'], 'string', 'max' => 32],
                  ['title', 'string', 'min' => 6],
                  [['Iva', 'video', 'title', 'cover', 'otherinfo'], 'string', 'max' => 255],
                  [['video', 'cover'], 'url', 'defaultScheme' => 'http'],
                  ['Iva', 'default', 'value' => 'Iva'],
                  ['live', 'default', 'value' => 0],
                  ['cover', 'default', 'value' => 'https://danjuan.oss-cn-shanghai.aliyuncs.com/webupload/T1Q5DmBCYT1RXrhCrK.jpg'],
                  ['videoStartPrefixSeconds', 'default', 'value' => 0],
                  ['videoEndPrefixSeconds', 'default', 'value' => 0],
                  ['skinSelect', 'default', 'value' => 0],
                  ['autoplay', 'default', 'value' => 0],
                  ['rightHand', 'default', 'value' => 0],
                  ['autoFormat', 'default', 'value' => 0],
                  ['bubble', 'default', 'value' => 1],
                  ['jumpStep', 'default', 'value' => 10],
                  ['tagTrack', 'default', 'value' => 0],
                  ['tagShow', 'default', 'value' => 0],
                  ['tagDuration', 'default', 'value' => 5],
                  ['tagFontSize', 'default', 'value' => 16],
                  ];
                  }
                  /**
                  * @inheritdoc
                  */
                  public function attributeLabels()
                  {
                  return [
                  'jjid' => '自增序号',
                  'jj' => '视频唯一标识码(32位自定义)',
                  'iszhutab1' => '默认即可',
                  'Iva' => '默认即可',
                  'appkey' => '默认即可',
                  'live' => '是否是直播流,默认为false',
                  'video' => '播放地址【必填】',
                  'title' => '视频标题【必填】',
                  'cover' => '选填,视频封面URL(http://.jpg|.png)',
                  'videoStartPrefixSeconds' => '选填,跳过片头,默认为0',
                  'videoEndPrefixSeconds' => '选填,跳过片尾,默认为0',
                  'skinSelect' => '选填,播放器皮肤,可选0、1、2,默认为0',
                  'autoplay' => '选填,是否自动播放,默认为false',
                  'rightHand' => '选填,是否开启右键菜单,默认为false',
                  'autoFormat' => '选填,是否自动选择最高清晰度,默认为false',
                  'bubble' => '选填,是否开启云泡功能,默认为true',
                  'jumpStep' => '选填,左右方向键快退快进的时间',
                  'tagTrack' => '选填,云链是否跟踪,默认为false',
                  'tagShow' => '选填,云链是否显示,默认为false',
                  'tagDuration' => '选填,云链显示时间,默认为5秒',
                  'tagFontSize' => '选填,云链文字大小,默认为16像素',
                  'uper' => '上传者【必填】',
                  'uptime' => '系统自动生成',
                  'otherinfo' => '其他|备注|备用字段',
                  ];
                  }
                  }
                  Vjj.php


                  10楼2016-05-20 12:30
                  回复
                    【醒目】验证规则public function rules()和标签public function attributeLabels()根据自己的需要可以做调整。


                    11楼2016-05-20 12:35
                    回复
                      <?php
                      namespace app\models;
                      use Yii;
                      use yii\base\Model;
                      use yii\data\ActiveDataProvider;
                      use app\models\Vjj;
                      /**
                      * VjjSearch represents the model behind the search form about `app\models\Vjj`.
                      */
                      class VjjSearch extends Vjj
                      {
                      /**
                      * @inheritdoc
                      */
                      public function rules()
                      {
                      return [
                      [['jjid', 'iszhutab1', 'live', 'videoStartPrefixSeconds', 'videoEndPrefixSeconds', 'skinSelect', 'autoplay', 'rightHand', 'autoFormat', 'bubble', 'jumpStep', 'tagTrack', 'tagShow', 'tagDuration', 'tagFontSize'], 'integer'],
                      [['jj', 'Iva', 'appkey', 'video', 'title', 'cover', 'uper', 'uptime', 'otherinfo'], 'safe'],
                      ];
                      }
                      /**
                      * @inheritdoc
                      */
                      public function scenarios()
                      {
                      // bypass scenarios() implementation in the parent class
                      return Model::scenarios();
                      }
                      /**
                      * Creates data provider instance with search query applied
                      *
                      * @param array $params
                      *
                      * @return ActiveDataProvider
                      */
                      public function search($params)
                      {
                      $query = Vjj::find();
                      // add conditions that should always apply here
                      $dataProvider = new ActiveDataProvider([
                      'query' => $query,
                      ]);
                      $this->load($params);
                      if (!$this->validate()) {
                      // uncomment the following line if you do not want to return any records when validation fails
                      // $query->where('0=1');
                      return $dataProvider;
                      }
                      // grid filtering conditions
                      $query->andFilterWhere([
                      'jjid' => $this->jjid,
                      'iszhutab1' => $this->iszhutab1,
                      'live' => $this->live,
                      'videoStartPrefixSeconds' => $this->videoStartPrefixSeconds,
                      'videoEndPrefixSeconds' => $this->videoEndPrefixSeconds,
                      'skinSelect' => $this->skinSelect,
                      'autoplay' => $this->autoplay,
                      'rightHand' => $this->rightHand,
                      'autoFormat' => $this->autoFormat,
                      'bubble' => $this->bubble,
                      'jumpStep' => $this->jumpStep,
                      'tagTrack' => $this->tagTrack,
                      'tagShow' => $this->tagShow,
                      'tagDuration' => $this->tagDuration,
                      'tagFontSize' => $this->tagFontSize,
                      'uptime' => $this->uptime,
                      ]);
                      $query->andFilterWhere(['like', 'jj', $this->jj])
                      ->andFilterWhere(['like', 'Iva', $this->Iva])
                      ->andFilterWhere(['like', 'appkey', $this->appkey])
                      ->andFilterWhere(['like', 'video', $this->video])
                      ->andFilterWhere(['like', 'title', $this->title])
                      ->andFilterWhere(['like', 'cover', $this->cover])
                      ->andFilterWhere(['like', 'uper', $this->uper])
                      ->andFilterWhere(['like', 'otherinfo', $this->otherinfo]);
                      return $dataProvider;
                      }
                      }
                      VjjSearch.php


                      12楼2016-05-20 12:37
                      回复
                        最后的视图
                        😂


                        来自iPhone客户端13楼2016-05-20 12:43
                        回复