Follow the steps below:
1) Create a domain model Entity say "Video" and set generalization as System.FileDocument. Add two attributes:
a)VideoName (String: 200)
b)VideoGUID(String unlimited)
2) Right click the Entity and click generate Overview pages. This will generate Overview and NewEdit pages for the "Video" entity. If you already have these then ignore this step.
Video Overview Page
3) Delete extra columns of the datagrid and you can keep only VideoName. You may keep VideoGUID column also which we will talk about later. If you are using a listview or some other data container then ignore this step.
Video NewEdit page
4) Open the Video_NewEdit page. Here you will upload new videos. You can remove some input widgets like Name, Size, etc and only keep VideoName and File uploader widget. This will allow you to select videos from your device and upload it and save as "Video" Entity objects. You can also double the file uploader widget and change the maximum file size that will suit your purpose. Default is 5MB.
NOW LET US MAKE THE FUNCTIONALITY TO PLAY VIDEO WHEN USER CLICKS ON VIDEO NAME
5) Come back to the Video_Overview page. If you are using datagrid to display the list of videos then proceed as follows:
a) Double click to open datagrid. Then Add onclick action as Call a Nanoflow. Then create a new nanoflow. Make sure that the nanoflow takes video object as input parameter.
b) If instead of this you are using some other data container to display the videolist, like a ListView, add buttons in place of the "VideoName " attribute in the list. This is because you want your VideoNames to be clickable. You can modify the button caption to be dynamic and display the "VideoName" and you can change the button style to "link" to avoid your VideoNames looking like actual buttons. And finally these buttons when clicked must call the Nanoflow we talked about above.
NOW OPEN THE NANOFLOW
6) Why do we need this nanoflow in the first place?
Ok, so to play a video you will need the Video Player widget which is available under tools in any page. But the problem is, this widget only accepts external URLs as input. Basically the Video Player widget is used to play Youtube, Vimeo, etc. videos. How to play the video that we have uploaded in the Video_NewEdit page as a "Video" object? We can play it if we get the GUID (Global User Identifier) associated with the object. And inside this nanoflow we will get the GUID.
NANOFLOW
7) First add a getGUID activity. The input should be object of type "Video" i.e. $Video and return variable should be a string say "Guid".
Now add a change entity activity. Select entity as $Video and go to members and select attribute VideoGUID and set it to the return variable of getGUID activity that is $Guid. Remember to check the commit option. Finally add a show page activity. Create a new page with ATLAS_Popup_Layout, give title Playing_video and page parameter as $Video.
NOW GO TO THE NEW PLAYING_VIDEO PAGE YOU JUST CREATED
7) Add a dataview container. Select the datasource as Page parameter passed. Now add a Video Player widget inside the dataview container. Now we need to configure the Video Player widget.
a) Keep the datasource type to dynamic. Now add the url: http://localhost:8080/file?guid={1}. And add parameter as attribute VideoGUID. This will fetch the video file using its GUID. Note: Here "8080" is the runtime port number on which your app is running. You can check this from Settings under your app. If your app is running on different port then adjust the url likewise.
Video Player
Go to Controls tab of Video Player widget and set AutoStart option to YES, so that video starts playing when popup page opens.
Finally go to Navigation and add a new item to open the Video_Overview page.
THAT'S IT. THE APP IS NOW READY.
Open the app and go to Video_Overview and try creating some new "Video" objects by clicking the new button. Add a video name and upload corresponding video. Now double click the newly added VideoName in the Video_Overview page to start playing the video.
Do write if you face any issues or need further clarifications. Happy coding!!
Hi Sheen,
take a string attribute in your domain model -> in the listView take a dynamic content column-> inside this take video player - > select domain model for this -> select string attribute for this.
When you are entering the data or creating the object of listview pass the youtube video link in the string attribute .