视频播放器无法显示

时间:2017-12-12 21:40:54

标签: javascript video

我使用视频播放器框架。我创建一个javascript函数,获取视频网址并将其发送到json数组。 这是我的javascript代码的一部分:

        var tvp_settings;

    function get_video_urls(hurl , durl , lurl) {
        alert(durl);
        /* SETTINGS */
        tvp_settings = {
            video:[
                {
                    type:'local',
                    path:{
                        Default: durl
                    },
                    previewImage:'https://elixirforum.com/uploads/default/original/2X/c/c7df6a9814561c3b152270e0f82fd01bf4f60564.jpg',

                    /* optional below */
                    showControls:true,/* show controls while video plays */
                    disableSeekbar:true,/* disable seekbar in controls */
                    showSkipBtn:true,/* show skip button */
                    skipBtnText:'باقیمانده',/* skip button message. */
                    skipEnableTime:5,/* time until skip button is enabled, in seconds */
                    link:'http://www.persianstacks.ir',/* click on video url link. Leave empty for none. */
                    target:'_blank',/* _blank/_parent (opens in new/same window)  */
                },

但视频播放器不显示视频。当我将此变量创建为函数时,视频播放器工作得非常好!

durl = 'sample video url';

什么是问题?

更新 这是我的完整代码:

<script>
    var tvp_settings;

    function get_video_urls(hurl , durl , lurl) {
        alert(durl);
        /* SETTINGS */
        tvp_settings = {
            video:[
                {
                    type:'local',
                    path:{
                        Default: durl
                    },
                    previewImage:'https://elixirforum.com/uploads/default/original/2X/c/c7df6a9814561c3b152270e0f82fd01bf4f60564.jpg',

                    /* optional below */
                    showControls:true,/* show controls while video plays */
                    disableSeekbar:true,/* disable seekbar in controls */
                    showSkipBtn:true,/* show skip button */
                    skipBtnText:'باقیمانده',/* skip button message. */
                    skipEnableTime:5,/* time until skip button is enabled, in seconds */
                    link:'http://www.persianstacks.ir',/* click on video url link. Leave empty for none. */
                    target:'_blank'/* _blank/_parent (opens in new/same window)  */
                },
                {
                    type:'local',
                    path:{
                        High: 'https://hw20.asset.aparat.com/aparat-video/5239d6e217bb2c2dc156b033141566358949397-144p__68773.mp4',
                        Default: 'https://hw20.asset.aparat.com/aparat-video/5239d6e217bb2c2dc156b033141566358949397-144p__68773.mp4',
                        Low: 'https://hw20.asset.aparat.com/aparat-video/5239d6e217bb2c2dc156b033141566358949397-144p__68773.mp4'
                    },
                    previewImage:'https://www.w3schools.com/w3css/img_lights.jpg',

                    /* optional below */
                    showControls:true,/* show controls while video plays */
                    disableSeekbar:false,/* disable seekbar in controls */
                    showSkipBtn:false,/* show skip button */
                    skipBtnText:'',/* skip button message. */
                    skipEnableTime:10,/* time until skip button is enabled, in seconds */
                    link:'',/* click on video url link. Leave empty for none. */
                    target:'_blank',/* _blank/_parent (opens in new/same window)  */
                    downloadPath:'../videos/fv.mp4',
                    captions:'',/* subtitles */
                    events: ''/*timed events over video */
                }
            ],

            endAction: 'stop',/* stop/loop/link (applies to last video in sequence) */
            endLink:'',/* end link action. Leave empty for none. */
            endTarget:'_parent',/* _blank/_parent (opens in new/same window)  */
            useWebmVideoFormat:false,/* true/false (Browser support for html5 video requires minimum of 2 video formats to cover all browsers, mp4 and ogv being preffered. If useWebmVideoFormat is true, then webm will be used instead of a ogv.) */
            useYoutubeApi:false,/* use youtube api to get video title, description, thumbnail */
            useYoutubeHighestQuality:false,/* true/false (use highest available quality for youtube video, if false, then it set to default chosen by youtube)  */
            defaultVolume:1,/* 0-1 */
            autoPlay:false,/* true/false (defaults to false on mobile)*/
            useContextMenu:true,/* true/false (use right click custom context menu, defaults to false on mobile)  */
            contextMenuText:'FURY_STUDIO',/* Custom text link in context menu. Leave empty for none like.  */
            contextMenuLink:'http://www.persianstacks.ir',/* url link  */
            contextMenuTarget:'_blank',/* _blank/_parent (opens in new/same window)  */
            useLogo:true,/* true/false  */
            logoPath:'http://localhost/mysite/wp-content/themes/furytemplate/videoplayer/data/logo.png',/* path to logo image  */
            logoLink:'http://codecanyon.net/user/Tean/portfolio',/* url link. Leave empty for none. */
            logoTarget:'_blank',/* _blank/_parent (opens in new/same window)  */
            logoTooltipText:'فیوری استودیو',/* logo tooltip text. */

            useControls:true,/* true/false (use video controls) */
            autoHideControls:false,/* auto hide controls: true/false. Defaults to false on mobile. */
            controlsTimeout:5000,/* time after which controls hide in fullscreen if mouse inactive, in miliseconds. */

            useEmbedCode:true,/* true/false (use embed code)  */
            useSharing:false,/* true/false (use social sharing)  */
            autoReuseMailForDownload: true,/* true/false. download backup for mobile, save email after first use and auto send all emails to the same address */
            closeRemovesEvents:true,/* true/false (when event is closed via close btn, it doesnt show in the same video any more)  */

            useTooltips:true,/* true/false (use tooltips on buttons)  */
            volumeTooltipText:'صدا',/* volume button tooltip text. */
            fullscreenTooltipText:'تمام صفحه',/* fullscreen button tooltip text. */
            captionsTooltipText:'Captions',/* caption button tooltip text. */
            qualityTooltipText:'کیفیت',/* quality button tooltip text. */
            downloadTooltipText:'دانلود',/* download button tooltip text. */
            videoInfoTooltipText:'اظلاعات ویدئو',/* video info button tooltip text. */
            shareTooltipText:'انتشار',/* share button tooltip text. */
            closeTooltipText:'بستن',/* close video info/share button tooltip text. */

            media_id:'player1'/* unique string for player identification (if multiple player instances were used, then strings need to be different!) */
        };
    }

    var hap_player;
    jQuery(document).ready(function($) {

        hap_player = $('#mainWrapper').videoGallery(tvp_settings);
        //initDemo();
    });
</script>

2 个答案:

答案 0 :(得分:0)

https://www.youtube.com/watch?v=tSSl-S1Kf3A HT视频播放器是最简单的手机视频播放器,具有强大的视频解码功能,可以轻松实现 支持您播放手机上存储的几乎所有视频文件。

HT视频播放器和视频转换器-Google Play上的应用(https://play.google.com/store/apps/details?id=com.htcreation.videoPlayerConverter

答案 1 :(得分:-1)

目标后的逗号:&#39; _blank&#39;可能是问题。 JSON在最后一个值之后不允许使用逗号。