Question
I'm developing a Tizen application that requires displaying two video players simultaneously. I've tried several approaches:
- Using AVPlay
- Using VideoJS
- Using HTML video tags
With VideoJS and HTML video tags, I couldn't get two videos to play simultaneously. I found this reference discussing the limitation: Multiple Video Tags Not Working
For AVPlay, the documentation and samples explain how to use webapis.avplay.* methods directly. My specific questions are:
- How can I get an object instance of AVPlay?
- How to bind it with an HTML object tag?
Here's my current HTML structure:
<object id="av-player-1" type="application/avplayer"></object>
<object id="av-player-2" type="application/avplayer"></object>
When I use webapis.avplay.* methods, the video appears only in the second object tag.
Answer
Problem Understanding
The user wants to implement multiple simultaneous video players in a Tizen application. While standard HTML5 video solutions (VideoJS and video tags) don't support this functionality, the AVPlay API should theoretically allow it, but there are implementation challenges.
Solution Methods
-
Creating AVPlay Instances:
- Use
webapis.avplay.createAVPlay()to create separate instances for each player - Store these instances in different variables to maintain control over each player
- Use
-
Binding to HTML Objects:
- After creating the AVPlay instance, use
setDisplayRect()to specify the display area - The display area should correspond to the dimensions of your HTML object elements
- After creating the AVPlay instance, use
-
Managing Multiple Players:
- Implement separate control logic for each player instance
- Ensure proper resource management to handle multiple video streams
Code Examples
// Create first player instance
var player1 = webapis.avplay.createAVPlay();
player1.open("http://example.com/video1.mp4");
player1.setDisplayRect(0, 0, 640, 360); // Coordinates for first player
player1.prepare();
// Create second player instance
var player2 = webapis.avplay.createAVPlay();
player2.open("http://example.com/video2.mp4");
player2.setDisplayRect(640, 0, 640, 360); // Coordinates for second player
player2.prepare();
// Start playback
player1.play();
player2.play();
Additional Tips
- Make sure to properly handle player states and errors for each instance
- Consider memory limitations when running multiple video players
- Test performance on target devices as multiple video playback can be resource-intensive
- For Tizen TV applications, check the latest documentation as some APIs might have specific requirements or limitations