Play video in Ubuntu scope with video Previewwidget

Source: Internet
Author: User
Tags git clone

In the previous routines, we explored how to use the audio Previewwidget to play music in scope. In this article, we'll show you how to use video Previewwidget to play a video.


Let's start by downloading my routines in the previous article:


git clone https://gitcafe.com/ubuntu/scopetemplates_audio.git


In order to join the video previewwidget, I added the following sentences to our routines:


Query.cpp
    r["VideoSource"] = "http://techslides.com/demos/sample-videos/small.mp4";    r["screenshot"] = Icons_[2].tostdstring ();

Here, we have added two "source" and "screenshot" in the video previewwidget. In practice, I found that if "screenshot" is not defined, the video will not be displayed and played correctly. The setting of this item is very important. Here we use a local image to show one of the videos (albeit less precise).

Preview.cpp
In preview, we have modified our code as follows:
    Result result = Previewquerybase::result ();    Previewwidget Listen ("tracks", "Audio");    {        Variantbuilder builder;        Builder.add_tuple ({            {"title", Variant ("This is the song title")},            {"Source", Variant (result["Musicsource"]. Get_string (). C_STR ())}        );        Listen.add_attribute_value ("Tracks", Builder.end ());    }    Previewwidget Video ("Videos", "video");    Video.add_attribute_value ("Source", Variant (result["VideoSource"].get_string (). C_STR ()));    Video.add_attribute_value ("screenshot", Variant (result["screenshot"].get_string (). C_STR ()));    Previewwidgetlist Widgets ({image, header, description});    if (result["Musicsource"].get_string (). Length ()! = 0) {        widgets.emplace_back (listen);    }    if (result["VideoSource"].get_string (). Length ()! = 0) {        widgets.emplace_back (video);    }    Reply->push (widgets);

To run our scope, we can see the following images:



When we click the Play button, it will automatically call the browser to play our video.
The source code for the entire project is: Git clone https://gitcafe.com/ubuntu/scopetemplates_video.git


Play video in Ubuntu scope with video Previewwidget

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.